Today I started learning Cocos2D-x game development.
Cocos2D-x game development framework is not very familiar at present, as the ITf logging woodworking I decided to deal with it a little bit.
Before getting started, we should popularize the following knowledge:
Scene (CCScene class) is an independent block in an app workflow. Scene is also called screents or "stages". An app may have multiple scenes, but only one of them can be activated at any time.
Cocos2D-x game interface in a scene CCScene unit, each CCscene has set a certain topic, including the background, Genie and scene rules. Connecting different CCscene forms a global game. So how can we switch back and forth between different scenarios after constructing our own scenarios? This is a beginner's guide !!!!!
In fact, cocos2d-x has been implemented for us as long as we need to directly call the function in the need of it.
CCDirector: sharedDirector ()-> replaceScene (SScene scene );
CCDirector: sharedDirector ()-> PushScene (SScene scene );
The switchover parameters are as follows:
CCTransitionJumpZoom
Purpose: Create a beating transition animation.
Parameter 1: Time of the transition action
Parameter 2: switch to the target scenario object
ReScene = CCTransitionJumpZoom: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionProgressRadialCCW
Purpose: Create a transition animation in the form of a slice, which is in the counterclockwise direction.
Parameter 1: Time of the transition action
Parameter 2: switch to the target scenario object
ReScene = CCTransitionProgressRadialCCW: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionProgressRadialCW
Purpose: Create a transition animation in the form of slices, clockwise
Parameter 1: Time of the transition action
Parameter 2: switch to the target scenario object
ReScene = CCTransitionProgressRadialCW: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionProgressHorizontal
Purpose: Create a horizontal transition animation,
Parameter 1: Time of the transition action
Parameter 2: switch to the target scenario object
ReScene = CCTransitionProgressHorizontal: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionProgressVertical
Purpose: Create a transition animation in vertical bar format,
Parameter 1: Time of the transition action
Parameter 2: switch to the target scenario object
ReScene = CCTransitionProgressVertical: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionProgressInOut
Purpose: Create a transition animation extending from the inside out,
Parameter 1: Time of the transition action
Parameter 2: switch to the target scenario object
ReScene = CCTransitionProgressInOut: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionProgressOutIn
Purpose: Create a transition animation that is extended from external to external,
Parameter 1: Time of the transition action
Parameter 2: switch to the target scenario object
ReScene = CCTransitionProgressOutIn: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionCrossFade
Purpose: Create a gradually transparent transition animation.
Parameter 1: Time of the transition action
Parameter 2: switch to the target scenario object
ReScene = CCTransitionCrossFade: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionPageTurn
Purpose: Create a page flip transition animation.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
Parameter 3: whether to Reverse flip
ReScene = CCTransitionPageTurn: create (t, s, false );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionFadeTR
Purpose: Create a blog transition animation from bottom left to top right.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionFadeTR: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionFadeBL
Purpose: Create a blog transition animation, from top right to bottom left.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionFadeBL: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionFadeUp
Purpose: Create a transition animation from bottom to top with a bar folded
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionFadeUp: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (s );
CCTransitionFadeDown
Purpose: Create a transition animation that is folded from top to bottom.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionFadeDown: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionTurnOffTiles
Purpose: Create a transition animation with the random square disappears.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionTurnOffTiles: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionSplitRows
Purpose: Create a transition animation for branch division switching.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionSplitRows: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionSplitCols
Purpose: Create a transition animation for partition switching.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionSplitCols: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionFade
Purpose: Create a switching animation that gradually transitions to the target color.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
Parameter 3: Target color
ReScene = CCTransitionFade: create (t, s, ccc3( 255, 0, 0 ));
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionFlipX
Purpose: Create a switchover animation with X axis reversal.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
Parameter 3: Reverse type enumeration variables up and down
KOrientationDownOver kOrientationLeftOver kOrientationRightOver kOrientationUpOver
ReScene = CCTransitionFlipX: create (t, s, kOrientationRightOver );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionFlipY
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
Parameter 3: Reverse type enumeration variables up and down
ReScene = CCTransitionFlipY: create (t, s
, KOrientationDownOver );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionFlipAngular
Purpose: Create an animation with Reverse Rotation Switching
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
Parameter 3: Reverse type enumeration variables up and down
ReScene = CCTransitionFlipAngular: create (t, s, kOrientationLeftOver );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionZoomFlipX
Purpose: Create an animation with a scaled X axis reversal Switch
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
Parameter 3: Reverse type enumeration variables up and down
ReScene = CCTransitionZoomFlipX: create (t, s, kOrientationLeftOver );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionZoomFlipY
Purpose: Create an animation with a scaled Y-axis reversal Switch
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
Parameter 3: Reverse type enumeration variables up and down
ReScene = CCTransitionZoomFlipY: create (t, s, kOrientationDownOver );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionZoomFlipAngular
Purpose: Create an animation with scaling and Reverse Rotation Switching
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
Parameter 3: Reverse type enumeration variables up and down
ReScene = CCTransitionZoomFlipAngular: create (t, s, kOrientationRightOver );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionShrinkGrow
Create an alternate transition Animation
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionShrinkGrow: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionRotoZoom
Create a transition animation with rotation, contraction, and Alternation
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionRotoZoom: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionMoveInL
Purpose: Create a transition animation from the left to the overwrite.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionMoveInL: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionMoveInR
Purpose: Create a transition animation pushed from the right to overwrite.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionMoveInR: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionMoveInB
Purpose: Create a transition animation pushed from the bottom to overwrite.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionMoveInB: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionMoveInT
Purpose: Create a transition animation pushed from top to overwrite.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionMoveInT: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionSlideInL
Purpose: Create a transition animation that pushes from the Left to top the old scene.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionSlideInL: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionSlideInR
Purpose: Create a transition animation that pushes the animation from the right to the original scene.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionSlideInR: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionSlideInT
Purpose: Create a transition animation that is pushed from the top and pushed out of the old scene.
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionSlideInT: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
CCTransitionSlideInB
Purpose: Create a transition animation pushed from the lower part and pushed out of the old scene
Parameter 1: duration of the Transition action
Parameter 2: objects in the switched target scenario
ReScene = CCTransitionSlideInB: create (t, s );
CCDirector: sharedDirector ()-> replaceScene (reScene );
These functions can be used to implement scenario switching.
You can download an example on the Internet.