One of the most refreshing features of cocos2d-x is the ability to convert directly between two different scenarios. For example: Fade in, zoom out, rotate, bounce, etc. Technically, a scene transformation is a conversion effect that is performed before a new scene is displayed and controlled.
The effect of transition jumps is achieved by Transitionscene series classes between scenes. Transitionscene inherits from scene, which is primarily a class of usage related to scene switching effects. such as Transitionfadedown, Transitionpageturn, Transitionjumpzoom and so on.
is the class diagram for Transitionscene:
The main switching effects are:
- transitionrotozoom rotate into
- transitionjumpzoom jump into
- transitionpageturn page Turn effect go
- Transit IONRADIALCCW Pendulum effect
- transitionmoveinl/transitionmoveinr/transitionmoveint/transitionmoveinb left/right/top/Bottom Enter the /li>
- transitionslideinl/transitionslideinr/transitionslideint/transitionslideinb slide in from left/right/top/bottom respectively
- Transitionshrinkgrow alternating into
- transitionflipx/transitionflipy X-axis (left/right)/y-axis (up/down)
- Transitionflipangular left upper right lower axis to turn on
- transitionzoomflipx/transitionzoomflipy X-Axis zoom in/out (left)/y-axis zoom in/out (up/down)
- Transitionfadetr/transitionfadebl/transitionfadeup/transitionfadedown the upper-right corner of the grid shows entry/Wangfang the lower left corner shows entry/bar upward display Enter/ Horizontal bar down display enter
- transitionsplitcols/transitionsplitrows vertical Bar Toggle Entry/Bar Toggle entry
- transitionzoomflipangular Upper-Left right-bottom-turn zoom-out effect
- Transitionfade fade into
- transitioncrossfade gradient enters
- transitionturnofftiles small squares disappears into
- TRANSITIONRADIALCCW/TRANSITIONRADIALCW Slice unwind
And more, you can see the official API.
The implementation of the scene transformation:
auto transitions = TransitionMoveInL::create(0.2f, scene);Director::getInstance()->replaceScene(transitions);
The transformation of the scene is controlled by the Director class, and by invoking the Replacescene (scene scene) method of the Director class, the scene can be switched directly using the incoming scene to switch the screen, and the current scenario is released. It is the most common way to switch scenes.
As mentioned earlier, a series of classes of scene transformations inherit from the scene class, so you can create a transition class to replace the scene to achieve the effects of various transitions.
' Static transitionmoveinl Create (float T, scene* scene); T in the method represents the time of the transition to Scene.
The above code is as follows:
(10) Scene conversion (transitions)