In my I've defined a CCLayer like this:
@interface MyLayer : CCLayer {
CCLayer * referenceLayer;
}
How should I declare it to use it in +(CCScene *) scene ?
Like this ?
@property (nonatomic, retain) CCLayer *referenceLayer;
In my I've defined a CCLayer like this:
@interface MyLayer : CCLayer {
CCLayer * referenceLayer;
}
How should I declare it to use it in +(CCScene *) scene ?
Like this ?
@property (nonatomic, retain) CCLayer *referenceLayer;
Since
+ (id)scene
is a class method, you cannot access an ivar/property from within it. One possible solution is having a static variable in your layer.m file, like in the following snippet:This simple approach has a drawback: you can only have one such layer around.