Transitioning between scenes

As mentioned in the previous recipe, scenes are the root CCNodes and only one can be running at a time. When switching between scenes, we can apply transitions to make the scene change more explicit and stylish. In this recipe, you can demo all of the built-in scene transitions.

Transitioning between scenes

Getting ready

Please refer to the project RecipeCollection02 for full working code of this recipe.

How to do it...

Execute the following code:

@implementation TransSceneMenu +(id) sceneWithString:(NSString*)str withCurrentTransition:(int)ct { //Create scene CCScene *s = [CCScene node]; TransSceneMenu *node = [[TransSceneMenu alloc] initWithString:str ...

Get Cocos2d for iPhone 1 Game Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.