Ccfinitetimeaction: The execution class of a limited action, that is, to execute a series of actions in chronological order. After the execution, the action ends. Here we will learn this class.
We can see that the action is mainly divided into two categories: ccactioninstanse (base class of instantaneous action) and ccactioninterval (base class of delayed action)
Ccactioninstanse (the base class of the instantaneous action ):
Cccallfunc: execution function ccflipx/Y: x/y flip cchide: Hide
Ccplace: Set the location ccreusegrid: Reuse grid ccshow: Display
Ccstopgrid: Stop grid cctogglevisibility: visible Switch
Ccactioninterval (the base class of the delayed action) is the most commonly used delayed action. There are many subclasses of ccactioninterval, which can be learned through the tests example that comes with the cocos2d-x.
The main actions are as follows:
Ccmoveto/ccmoveby: Move ccscaleto/ccscaleby: Zoom ccrotateto/ccrotateby: Rotate
Ccskewto/ccskewby: Twisted ccjumpto/ccjumpby: Jump ccbezierto/ccbezierby: besell Curve
Ccbink: Blinking ccfadein/ccfadeout: fade in and fade out cctintto/cctintby: Dye
Ccspawn: Synchronous ccrepeat/ccrepeatforever: yes/no repetition
Ccdelaytime: latency
The following is an example: grossini is a genie
CCActionInterval actionBy = CCJumpBy.actionWithDuration(2, new CCPoint(100, 100), 50, 4);CCFiniteTimeAction actionByBack = actionBy.reverse();grossini.runAction(CCSequence.actions(actionBy, actionByBack));
In general, we can write in this way, and combine several actions together to realize the actions of the genie.
CCAction action = CCSequence.actions(CCSpawn.actions(CCAnimate.actionWithAnimation(animation, false),CCMoveBy.actionWithDuration(0.28f, position),CCCallFuncND.actionWithTarget(this, onWalkDone, tag)));grossini.runAction(action);
Ccsequence is an action sequence. It combines several actions in sequence and then executes them in sequence.
Ccspawn combines several actions and executes them simultaneously (in parallel). The execution time is subject to the longest action.
The parameter is an action array of ccfinitetimeaction [] actions, such as ccmoveby, ccskewby, and ccscaleby. In general, put a cccallfunc In the last action of ccspawn, and put a callback function (ondomaindone) as the processing after the action is executed (for example, display information and character orientation ).