Cocos2d push scene with parameter, the parameter is reset after push. How to troubleshoot? Thoughts?

Posted by user72693 on Programmers See other posts from Programmers or by user72693
Published on 2012-11-15T05:01:26Z Indexed on 2012/11/15 5:09 UTC
Read the original article Hit count: 143

Filed under:
|

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?

© Programmers or respective owner

Related posts about ios

Related posts about objective-c