iphoneioscocos2d-iphonecclayer

how push scene in cocos2d and pass parameters


i want know if there is a way to push a scene in cocos2d 2.0 and pass some parameter to this pushed scene, for example, i know that to push a scene i use this:

[[CCDirector sharedDirector] pushScene:[HelloWorldLayer scene]];

and this push the helloworldlayer, that is a simple layer:

// HelloWorldLayer
@interface HelloWorldLayer : CCLayer
{
}

// returns a CCScene that contains the HelloWorldLayer as the only child
+(CCScene *) scene;

@end

but i want pass to this layer some parameter, so when the layer is pushed i can use the parameter i passed.

how i can do it?


Solution

  • you can do something like +(CCScene *) sceneWithParameter:(ParameterType)parameter; instead of +(CCScene *) scene;