Ok, first I am confused about the onExit function. When is it called? I thought it would only be called when the object exits the screen but mine seems to be called when it enters the screen as well?
I am probably just doing something stupid. I move from the MainMenuScene to the first level scene using the following lines:
'Level1Scene * lvl1Scene = [[Level1Scene alloc] init];
[[Director sharedDirector] replaceScene:lvl1Scene];
[[Director sharedDirector] replaceScene: [RotoZoomTransition transitionWithDuration:1.5 scene: lvl1Scene]];'
Level1Scene then adds Level1Layer in its constructor with the following lines (left out the standard constructor lines):
'Level1Layer * level1 = [[Level1Layer alloc] init];
[self addChild:level1 z:1];'
My Level1Layer loads fine but the onExit is called right near the start, not sure why? It is also called when I switch to another scene (which I expected).
Also, my big issue is confusing with what to do before switching scenes. Currently I call the following two lines every time I am about to switch scenes:
'[self unschedule:@selector(decTime)];
[self removeAllChildrenWithCleanup:YES];'
I'm not sure if thats the right thing to do or not. I thought about putting them in the onExit function but since it gets called at the start I end up with a layer with nothing on it.
The other problem is that when I switch to a different scene, the decTime function that is called by the timer gets called again and I get a "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType setString:]: unrecognized selector sent to instance 0x533f0d0'" error.
It comes up with different types calling the setString each time for some reason.
I've read the threads on here about removeAllChildrenWithCleanup but I still have no idea what I'm doing. Pretty sure I am doing something completely wrong that is giving me so many problems
Oh, and I edited the CocosNode.m file as posted in the other thread by Riq to fix the bug in 0.72 (which is the version I'm currently using)
Thanks for any help :)