Cocos2d push scene with parameter, the parameter is reset after push. How to troubleshoot? Thoughts?
- by user72693
In the helloWorldLayer.m, I push a scene with some parameter like this
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:0.2 scene:[RootLayer sceneWithInt:123]]];
where the RootLayer I have a modified method
+(CCScene *) sceneWithInt:(int) i{
CCScene *scene = [CCScene node];
GameplayLayer *layer = [[GameplayLayer node] retain];
[layer setTestInt:i];
[scene addChild: layer z:0 tag:100];
return scene;
}
In the above, the "GameplayLayer" has an Int property "TestInt" which I would like to set it before this layer is push. However, the moment the GameplayLayer is loaded, that TestInt property is reset to 0. It is not passing correctly.
I remember in my last project this can be done. How to troubleshoot this?