Cocos2d-x adds scene transition animation

The default scene switching of Cocos2d-x is too simple.
However, the Cocos2d-x framework has prepared some transition animations for us in advance, and it is easy to use.

Ordinary transition callback function:

void HelloWorld::startCallback(Ref* pSender) {
    
    
	auto reScene = newScene::createScene();
	Director::getInstance()->replaceScene(reScene);
}

Added transition callback function of transition animation:

void HelloWorld::startCallback(Ref* pSender) {
    
    
	auto myNewScene = newScene::createScene();
	auto reScene = TransitionFadeTR::create(0.5f, myNewScene);
	Director::getInstance()->replaceScene(reScene);
}

As shown in the above code, to add a transition animation for scene switching, we only need to add a statement, that is, add an object of the transition animation class.
Among the two parameters, the first parameter is floating-point data, which is the duration of the transition animation; the second parameter is the scene object after the transition animation is played.
At this time, the parameters when we use the director class to switch scenes need to be set to the added transition animation class object.

Several common transition animation classes

TransitionFadeTR grid transition animation from bottom left to top right

TransitonJumpZoom Jumping transition animation

TransitonCrossFade cross-fading transition animation

TransitionSplitClos Split the transition animation of the interface by column

TransitonTurnOffTiles generates a transition animation of random tiles

complete.

Guess you like

Origin blog.csdn.net/weixin_45711556/article/details/108418039