(10) Scene conversion (transitions)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.