开发者

How do I stop init from being called from another class in Cocos2d?

In Cocos2d I have 2 classes, HelloWorldScene (The standard main class for the Cocos2d template) and OptionsScene. I launch OptionsScene from HelloWorldScene and than when I'm done using OptionsScene I launch HelloWorldScene from OptionScene.

My problem is init is called when I launch HelloWorldScene from OptionsScene and I don't want to let init be called because it essentially resets my game.

Here is the code I am using to launch HelloWorldScene from OptionsScene:

HelloWorld *hw = [HelloWorld alloc];
[hw loadWithParticleColor:particleColor andBloppleColor:bloppleColor];
[hw release];
[[CCDirector sharedDirector] replaceScene:[CCTransitionRotoZoom transitionWithDuration:1.0 scene:[HelloWorld node]]];

Any hin开发者_运维知识库ts or solutions would be of great help!


Since it's a relatively simple hierarchy, you can use the CCDirector's pushScene: method and add the OptionsScene on top of the HelloWorldScene. Dismiss with popScene and your HelloWorldScene should appear in the state you left it in.

Replacing the scene is usually used when you want to conserve resources, which is not necessary in this case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜