Transitions and setting layers / scenes in cocos2d iPhone

I want to configure the transition between two levels (after one level is completed, use one of the cocos2d slick transition to go to the next level). In my implementation of GameLayer, I have methods for creating things like [self buildLevel: 3] for creating a game board. What do I need to do to create a new GameLayer or Layer node or GameScene or Scene node in order to be able to do things like:

GameLayer * nextLevelLayer;

[nextLevelLayer buildLevel: 4];

... make the transition between level 3 and level 4

Perhaps I set out my code in a complete misunderstanding of Objective C. I assume that you cannot configure the new GameLayer in the init code, since it will hang, constantly creating new nodes. I probably have too much code for setting up the playing field in my GameLayer initialization code, how do you guys usually handle this? Do you set a flag before planning a selector for the main game loop, then, if the flag is set, adjust the level in the main game loop or is there a better way to do this?

Thanks in advance!

+6
objective-c iphone cocos2d-iphone
source share
1 answer

For those who may be interested, here is what I did:

GameScene * gs = [GameScene node]; [[Director sharedDirector] runScene: gs]; [[Director sharedDirector] replaceScene: [ShrinkGrowTransition transitionWithDuration:0.5 scene: gs]]; 

This was done as part of the implementation of GameLayer after the level was completed.

+14
source share

All Articles