CCTransition with the same scene


Is it possible to imitate a transition (CCTransitionPageTurn) with the same scene? For example there is a scene that is changing and I want to make a transition between its previous and new state.


the easiest way if you only want fadein fadeout transitions would be to place a large sprite on the top layer of your game and gradually change its opacity with .setOpacity(), if you want to make the more fancy transition then i would probably do an init with the states for example:

bool HelloWorld::init()
    // 1. super init first
    if ( !CCLayer::init() )
        return false;
        state = CCUserDefault::sharedUserDefault()->getIntegerForKey("state");
         case 1:
         //state 1
         case 2:
         //state 2
//when you want to replace the scene 
CCScene *sameScene;
sameScene = Splash::scene();
CCDirector::sharedDirector()->replaceScene(ZoomFlipXLeftOver::transitionWithDuration(1.0f, sameScene));

note that i haven’t tested this, just what i would do to achieve something like this, there might be an easier way tho.


I think about a different approach. What if to take a snapshot of the current scene and to replace the scene with its own snapshot? The only problem - how to make a snapshot?


i just took a look at CCTransition.cpp and fade transitions are new layers and camera movements for flip transitions, so you should be able to replicate them easily in your scene without replacing the scene.


To be honest, I don’t understand what you mean :frowning:


try this->runAction(CCOrbitCamera::actionWithDuration(1.0f, 1, 0, 270, 90, 90, 0)); in your scene :wink:


Thank you! That is exactly what I want.