I been pulling my hair out over this, I can't seem to figure this simple issue out.
I have a class which extends CCNode, here's the header:
#import "CCNode.h"
@interface ContentPane : CCNode
@property (nonatomic, strong) CCNode * _rockPath1;
@property (nonatomic, strong) CCNode * _rockPath2;
@property (nonatomic, strong) CCNode *_secondPath1;
@property (nonatomic, strong) CCNode *_secondPath2;
@property (nonatomic) int map;
-(void)generatePane;
@end
I am trying to initialize this class so that the visibility of _rockPath1, _rockPath2, etc is hidden. However, the values I set in at init aren't being respected. Here's my init, in my init I'm simply trying to set the position of ._rockPath1 because I know that line of code works because I have it elsewhere in my program and it works fine.
- (id)init {
self = [super init];
self.map = 0x11111111;
CCLOG(@"WHAT");
//_rockPath1.position = ccp(90,90);
self._rockPath1.position = ccp(90,90);
return self;
}
After my class is initialized, _rockPath1 does not have the position I set for it, it still has the values defined in SpriteBuilder. Strangely enough, map is set to the correct values, but the position is not.
Seeing that you are using SpriteBuilder, and assuming you make the assignments to _rockPath
etc from SpriteBuilder (doc root var), you have to do the initialization of the default values in didLoadFromCCB
(and remove your init method):
-(void) didLoadFromCCB
{
self.map = 0x11111111;
_rockPath1.position = ccp(90,90);
}
The thing is, the init method runs the instance the node is created which means it runs way before the assignments from CCBReader will be applied.