Sunday, 2 June 2013

How to change from one scene to another(scene transition): cocos2d

First import the next scene name in the implementation file:
    
     #import "newSceneName .m"


Then call the next scene using the following line:

    [[CCDirector sharedDirector] replaceScene:[newSceneName scene]];


There are also some special transitions available on cocos2d. some of the examples are give below:

        // For Transition radial clockwise
            [[CCDirector sharedDirector] replaceScene:
                    [CCTransitionRadialCW transitionWithDuration:1.0f scene:[newSceneName scene]]];

        // For Transition shrink grow
            [[CCDirector sharedDirector] replaceScene:
                    [CCTransitionShrinkGrow transitionWithDuration:1.0f scene:[newSceneName scene]]];

        // For Transition split rows
            [[CCDirector sharedDirector] replaceScene:
                    [CCTransitionSplitRows transitionWithDuration:1.0f scene:[newSceneName scene]]];

        // For Transition turn off tiles
            [[CCDirector sharedDirector] replaceScene:
                    [CCTransitionTurnOffTiles transitionWithDuration:1.0f scene:[newSceneName scene] ]];

        // For Transition zoom and flipping X with orientation
            [[CCDirector sharedDirector] replaceScene:
                    [CCTransitionZoomFlipX transitionWithDuration:1.0f
                    scene:[newSceneName scene] orientation:kOrientationRightOver]];

No comments:

Post a Comment