Cocos2d-x cainiao intern study-scenario Switching

Source: Internet
Author: User

Now, let's continue with scenario switching. cocos2d supports status switching for many special effects. Run the code first. Let's analyze it slowly! Here is the creation function [cpp] CCScene * Helloworld: scene () {CCScene * scene = NULL; do {// 'Scene 'is an autorelease object scene = CCScene: node (); here we create a scenario CC_BREAK_IF (! Scene); // 'player' is an autorelisted object HelloWorld * layer = HelloWorld: node (); a layer CC_BREAK_IF (! Layer); // add layer as a child to scene-> addChild (layer); then add layers to the scene to display this layer in the scene ~, Of course, it can be multiple layers ~} While (0); // return the scene return scene;} the above Code creates the Helloworld scenario and then creates a layer. Add this layer to the scene. Do you still remember to add the button code in the init () function... after a button is added, we can modify the response function relative to it: [cpp] CCMenuItemImage * pCloseItem2 = CCMenuItemImage: itemFromNormalImage ("play1.png", "play2.png", this, menu_selector (HelloWorld: menuTestCallback); this HelloWorld: menuTestCallback is a function name. We need to write this function by ourselves. CC_BREAK_IF (! PCloseItem2); pCloseItem2-> setPosition (ccp (s. width/2, s. height-100); set the button position CCMenu * pMenu = CCMenu: menuWithItems (pCloseItem2, NULL); set the menu item pMenu-> setPosition (CCPointZero); CC_BREAK_IF (! PMenu); this-> addChild (pMenu, 1); The 1 after adding a menu... represents a level. The smallest layer is code in init () on the surface. A button is created and placed in the menu. Then add the menu to the scenario... the following is the code for implementing the key switching special effects... [cpp] void HelloWorld: menuTestCallback (CCObject * pSender) {CCScene * scene = HelloWorld: scene (); Note the Scene () here. This is the scenario for switching, I am writing about this scenario, so it is my own scenario .. haha, but we are looking at the excessive effects of switching .. CCDirector: sharedDirector ()-> replaceScene (CCTransitionJumpZoom: transitionWithDuration (1.2f, scene);} normal failover without excessive use cases, that is, CCDirector: shareddire () -> replaceScene (scene); pay attention to this CCTransitionJumpZo Om:, This is the switching effect! Replace this to achieve various effects! What are the specific effects? Here we reprinted the full blog: transitionWithDuration (t, s) two parameters. The first one is time, and the format is a floating point similar to 1.2f. The second is the scenario to be switched to. There is an introduction to bill man's personal originality. You are welcome to repost it. For details, please note the address and the column address of bill man. http://blog.csdn.net/bill_manCCTransitionJumpZoom::transitionWithDuration (T, s); // Skip. This scenario will be reduced first, and then jump in CCTransitionFade: transitionWithDuration (t, s); // fade out and fade out in the original scenario, new scene fades in CCTransitionFade: transitionWithDuration (t, s, ccWHITE); // if the previous function contains three parameters, the third parameter is the fade-out color CCTransitionFlipX :: transitionWithDuration (t, s, hour); // The left turn of the x-axis CCTransitionFlipX: transitionWithDuration (t, s, hour); // The right turn of the x-axis CCTransitionFlipY, kOrientationUpOver); // CCTransitionFlipY: transitionWithDuration (t, s, kOrientationDownOver) on the Y axis; // transitionWithDuration (t, s, timeout) on the Y axis ); // CCTransitionFlipAngular: transitionWithDuration (t, s, kOrientationRightOver) with an angle to the left; // right-turning orientation with an angle to the right: transitionWithDuration (t, s, callback ); // returns the value of transitionWithDuration (t, s, kOrientationRightOver). // returns the value of transitionWithDuration (t, s, kOrientationUpOver) on the X axis ); // rotate the Y axis with the zoom effect: transitionWithDuration (t, s, kOrientationDownOver); // perform the following operations on the Y axis with the zoom effect: transitionWithDuration (t, s, kOrientationLeftOver ); // zoomflipangular with an angle rotation: transitionWithDuration (t, s, kOrientationRightOver); // right turn CCTransitionShrinkGrow with an angle rotation :: transitionWithDuration (t, s); // exchanged CCTransitionRotoZoom: transitionWithDuration (t, s); // exchanged CCTransitionMoveInL: transitionWithDuration (t, s ); // The new scene is moved from left to overwrite CCTransitionMoveInR: transitionWithDuration (t, s); // the new scene is moved from right to overwrite CCTransitionMoveInT: transitionWithDuration (t, s ); // The new scenario covers CCTransitionMoveInB: transitionWithDuration (t, s) from top to bottom; // the new scenario covers CCTransitionSlideInL: transitionWithDuration (t, s ); // The original scenario CCTransitionSlideInR: transitionWithDuration (t, s) is introduced from the left. // The original scenario CCTransitionSlideInT: transitionWithDuration (t, s) is introduced from the right ); // The original scenario CCTransitionSlideInB: transitionWithDuration (t, s) is introduced from the previous scenario. // The original scenario needs to be checked whether the opengl version supports CCConfiguration :: sharedConfiguration ()-> getGlesVersion () <= GLES_VER_1_0 if true, CCTransitionCrossFade: transitionWithDuration (t, s) is not supported; // fade-in and cross is performed simultaneously. CCTransitionRadialCCW :: transitionWithDuration (t, s); // clockwise switch to CCTransitionRadialCW: transitionWithDuration (t, s); // you need to set the camera to switch to the following two values counterclockwise: shareddire () -> setDepthTest (true); CCTransitionPageTurn: transitionWithDuration (t, s, false); // page flip, front flip CCTransitionPageTurn: transitionWithDuration (t, s, true ); // flip the page, and then flip the CCTransitionFadeTR: transitionWithDuration (t, s); // wave forward to the right: transitionWithDuration (t, s); // wave the CCTransitionFadeUp :: transitionWithDuration (t, s); // up the blind CCTransitionFadeDown: transitionWithDuration (t, s); // down the blind CCTransitionTurnOffTiles: transitionWithDuration (t, s ); // random small square CCTransitionSplitRows: transitionWithDuration (t, s); // cut CCTransitionSplitCols: transitionWithDuration (t, s) by row; // cut by Column

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.