Cocos2d-x Study Notes (15) (Action)

Source: Internet
Author: User
The action provided by the Cocos2d-x, which can be used as long as it is a CCNode object. 1. Common Operations: 1) runAction (cocos2d: CCAction * action) execute an action action2) CCDirector: sharedDirector ()-getActionManager ()-pauseTarget (cocos2d :: CCObject * pTarget) pause

The action provided by the Cocos2d-x, which can be used as long as it is a CCNode object. 1. Common Operations: 1) runAction (cocos2d: CCAction * action) // execute an action 2) CCDirector: sharedDirector ()-getActionManager ()-pauseTarget (cocos2d:: CCObject * pTarget) // pause

The action provided by the Cocos2d-x, which can be used as long as it is a CCNode object.

1. Common operations are as follows:

1) runAction (cocos2d: CCAction * action) // execute an action

2) CCDirector: sharedDirector ()-> getActionManager ()-> pauseTarget (cocos2d: CCObject * pTarget) // pause the action of the target pTarget object

3) CCDirector: shareddire()-> getActionManager ()-> ...... // Continue the action of the target object

4) stopAction (cocos2d: CCAction * action)/action of the stopped target object

StopActionByTag (int tag) // tag value of the stopped target action object

5) CCDirector: shareddire()-> getActionManager ()-> removeAction (cocos2d: CCAction * action) // Delete the target action object

6) CCDirector: sharedDirector ()-> getActionManager ()-> removeActionByTag (unsigned int tag, cocos2d: CCObject * pTarget)

Parameter 1: tag value of the action to be deleted

Parameter 2: target object of the action to be deleted

7) pauseSchedulerAndActions () // pause all actions and even update functions

CCSet * CCDirector: shareddire-> getActionManager ()-> pauseAllRunningActions () // pause all actions, and store the records of paused action objects in the CCSet collection.

8) resumeSchedulerAndActions ()

CCDirector: sharedDirector ()-> getActionManager ()-> resumeTargets (cocos2d: CCSet * targetsToResume) // use the recorded paused CCSet recovery action

9) stopAllActions () // stop all actions

10) CCDirector: shareddire()-> getActionManager ()-> removeAllAction () // delete all actions

2. Explanation of 49 common actions

1) CCMoveTo: create (float duration, const CCPoint & position) // create a mobile action

Parameter 1: Time of moving to the target coordinate

Parameter 2: Target coordinate

2) CCMoveBy: create (float duration, const CCPoint & position) // create a mobile action. CCMoveBy supports the reverse () function to obtain its reverse action.

Parameter 1: Time of moving to the target coordinate

Parameter 2: Target coordinate

3) CCScaleTo: create (float duration, float s) // create a scaling action

Parameter 1: The time (in seconds) required to scale)

Parameter 2: scaling ratio. The value is 1 and the original size. The value is greater than 1 and the value is greater than 1. The value is smaller than 1.

4) CCScaleBy: create (float duration, float s) // create a scaling action. CCScaleBy supports the reverse () function to obtain its reverse action.

Parameter 1: The time (in seconds) required to scale)

Parameter 2: scaling ratio

5) CCRotateTo: create (float duration, float fDeltaAngle) // create a rotating action

Parameter 1: The time (in seconds) required to rotate to a specific angle)

Parameter 2: rotation angle, ranging from 0 to 360

6) CCRotateBy: create (float duration, float fDeltaAngle) // create a rotating action. The reverse () function is supported to obtain the reverse action.

Parameter 1: The time (in seconds) required to rotate to a specific angle)

Parameter 2: rotation angle, ranging from 0 to 360

7) CCSkewTo: create (float t, float sx, float sy) // create a skewed action

Parameter 1: Time required to tilt to a specific angle (seconds)

Parameter 2: tilt angle of the X axis

Parameter 3: Y-axis Skew Angle

8) CCSkewBy: create (float t, float sx, float sy) // creates a skewed action. It supports the reverse () function to obtain the direction action.

Parameter 1: Time required to tilt to a specific angle (seconds)

Parameter 2: tilt angle of the X axis

Parameter 3: Y-axis Skew Angle

9) CCjumpTo: reate (float duration, const CCPoint & position, float height, int jumps) // create a hop action

Parameter 1: when the action is completed (in seconds)

Parameter 2: Target Location

Parameter 3: Hop height

Parameter 4: Number of hops required to jump to the target point

10) CCjumpBy: reate (float duration, const CCPoint & position, float height, int jumps) // creates a hop action. It supports the reverse () function to obtain the direction action.

Parameter 1: when the action is completed (in seconds)

Parameter 2: Target Location

Parameter 3: Hop height

Parameter 4: Number of hops required to jump to the target point

11) CCBezierTo: create (float t, const ccBezierConfig & c) // create an action for the beiser curve Motion

Parameter 1: time required for the beiser curve movement (seconds)

Parameter 2: ccBezierConfig structure:

Typedef struct _ ccBezierConfig {

CCPoint endPosition; // end point

CCPoint controlPoint_1; // Control Point 1

CCPoint controlPoint_2; // Control Point 2

} CcBezierConfig;

12) CCBezierBy: create (float t, const ccBezierConfig & c) // create an action for the beiser curve motion. The reverse () function is supported to obtain the direction action.

Parameter 1: time required for the beiser curve movement (seconds)

Parameter 2: ccBezierConfig struct

13) CCFadeIn: create (float d) // create a gradient action. The time required for the parameter gradient (seconds)

14) CCFadeOut: create (float d) // create an action for the gradient to disappear. The time required for the parameter gradient (in seconds)

15) CCTintTo: create (float duration, GLubyte red, GLubyte green, GLubyte blue) // create a color change action

Parameter 1: time required for color change (seconds)

Parameter 2: red

Parameter 3: green component

Parameter 4: Blue

16) CCTintBy: create (float duration, GLubyte red, GLubyte green, GLubyte blue) // creates a color change action. The reverse () function is supported to obtain the direction action.

17) CCBlink: create (float duration, unsigned int uBlinks) // create a blinking action

Parameter 1: The time (in seconds) when the flash is completed)

Parameter 2: Number of flashes

18) CCDelayTime: create (float d) // create a delayed action. The parameter is the delay time (seconds)

19) CCOrbitCamera: create (float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) // create a spherical coordinate trajectory for rotation

Parameter 1: time required for the rotating track

Parameter 2: actual radius

Parameter 3: radius difference

Parameter 4: Start Z angle

Parameter 5: rotate the Z-angle difference

Parameter 6: Start X Angle

Parameter 7: rotation X-angle difference

20) CCCardinalSplineTo: create (float duration, CCPointArray * points, float tension) // create a spline trajectory action

Parameter 1: time required to complete the trajectory

Parameter 2: coordinate array of control points

Parameter 3: Fit degree. The value is 0, and the path is the softest.

21) CCCardinalSplineBy: create (float duration, CCPointArray * points, float tension) // create a spline trajectory action and support the reverse () function

22) CCCatmullRomTo: create (float dt, CCPointArray * points) // create a spline interpolation trajectory

Parameter 1: time when the track is completed

Parameter 2: coordinate array of control points

23) CCCatmullRomBy: create (float dt, CCPointArray * points) // creates a spline interpolation trajectory and supports the reverse () function.

24) CCFollow: create (CCNode * pFollowedNode, const CCRect & rect = CCRectZero) // create a follow action

Parameter 1: target object to be followed

Parameter 2: follows the range and no longer follows when the range is left.

25) CCEaseBounceIn: create (cocos2d: CCActionInterval * pAction) // Let the target action be resilient and start to rebound at the starting position of the target action. The parameter is the target action.

26) CCEaseBounceOut: create (cocos2d: CCActionInterval * pAction) // Let the target action be resilient and start to rebound at the end of the target action. The parameter is the target action.

27) CCEaseBounceInOut: create (cocos2d: CCActionInterval * pAction) // Let the target action be resilient and start to rebound at the start and end positions of the target action. The parameter is the target action.

28) CCEaseBackIn: create (cocos2d: CCActionInterval * pAction) // assign the target action a force return and use the starting position of the target action as the Force return point.

29) CCEaseBackOut: create (cocos2d: CCActionInterval * pAction) // assign the target action a force return and use the end position of the target action as the Force return point.

30) CCEaseBackInOut: create (cocos2d: CCActionInterval * pAction) // assign a force return to the target action, and use the start and end positions of the target action as the Force return point.

31) CCEaseElasticIn: create (cocos2d: CCActionInterval * pAction) // enable the elasticity of the target action and the elasticity of the target action starting position

32) CCEaseElasticOut: create (cocos2d: CCActionInterval * pAction) // enable the elasticity of the target action and the elasticity of the target action endpoint

33) CCEaseElasticInOut: create (cocos2d: CCActionInterval * pAction) // enable the elasticity of the target action and the elasticity of the start and end positions of the target action

34) CCEaseExponentialIn: create (cocos2d: CCActionInterval * pAction) // start the target action slowly.

35) CCEaseExponentialOut: create (cocos2d: CCActionInterval * pAction) // causes the target action to be terminated slowly.

36) CCEaseExponentialInOut: create (cocos2d: CCActionInterval * pAction) // causes the target action to start and stop slowly.

37) CCEaseRateAction: create (cocos2d: CCActionInterval * pAction, float fRate) // set the speed of the target action. Parameter 1: target action, parameter 2: Rate

38) CCEaseSineIn: create (cocos2d: CCActionInterval * pAction) // Let the target action slow to fast

39) CCEaseSineOut: create (cocos2d: CCActionInterval * pAction) // set the target action to slow

40) CCEaseSineInOut: create (cocos2d: CCActionInterval * pAction) // slow the target action from slow to fast, and then from fast to slow

41) CCSpeed: create (cocos2d: CCActionInterval * pAction, float fSpeed) // doubles the running speed of the target action. Parameter 1: target action, parameter 2: double speed

42) CCSpawn: create (cocos2d: CCFiniteTimeAction * pAction1,...) // enables multiple actions to be executed simultaneously. Parameter 1: Variable Parameter of the target action

43) CCSequence: create (cocos2d: CCFiniteTimeAction * pAction1,...) // Let multiple actions be executed one by one in the order of order. parameters: variable parameters of the target action

If you want to perform all the actions in a sequence in sequence, you can perform the following operations.

CCActionInterval* move = CCMoveTo::create(2,cpp(300,sp->getPositionY()));CCActionInterval* scale = CCScaleTo::create(2,3);CCFiniteTimeAction* seq = CCSequence::create(move,scale,NULL);sp->runAction(seq);

If you want to reverse all the actions in a sequence, you can perform the following operations:

CCActionInterval* move = CCMoveBy::create(2,cpp(300,sp->getPositionY()));CCActionInterval* scale = CCScaleBy::create(2,3);CCFiniteTimeAction* seq = CCSequence::create(move,scale,NULL);sp->runAction(seq);CCFiniteTimeAction* reverseSeq = CCSequence::create(seq,seq->reverse(),NULL);sp->runAction(reverseSeq);
44) CCRepeat: create (cocos2d: CCFiniteTimeAction * pAction1, unsigned int times) // Let the target action repeat, the target action can be CCSequence, CCSpawn

45) CCRepeatForever: create (cocos2d: CCFiniteTimeAction * pAction1, unsigned int times) // Let the target action perform a permanent repetitive motion, with the target as 44

46) CCCallFunc: create (cocos2d: CCObject * pSelectorTarget, SEL_CallFunc selector) // create a callback and call a callback method without Parameters

Parameter 1: target object
Parameter 2: Target callback function

47) CCCallFuncN: create (cocos2d: CCObject * pSelectorTarget, SEL_CallFunc selector) // create a callback and call the callback method with one parameter

48) CCCallFuncND: create (cocos2d: CCObject * pSelectorTarget, SEL_CallFunc selector, void * d) // create a callback and call the callback method with two parameters

Parameter 1: target object

Parameter 2: Target callback function

Parameter 3: it can be of any type

49) CCAnimate: animation.

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.