Odustggg Personal Original, welcome to reprint, reprint please indicate the source, http://blog.csdn.net/odustggg/article/details/8187843
References: http://cn.cocos2d-x.org/document
I. Concept of latency
Actions that take some time to complete, so almost all delayed actions use the execution time as the parameter. The common base class of delayed actions is the ccactioninstant class.
The cocos2d-x provides the following latency actions:
Ccmoveto: move to, ccmoveby: Move ccrotateto: rotate to, ccrotateby: Rotate ccscaleto: Zoom to, ccscaleby: Scale ccskewto: shear to, ccskewby: Shear cctintto: color gradient to, cctintby: color gradient ccfadein: fade in, ccfadeout: fade out ccfadeto: Change opacity to ccblink: set the number of flashes ccjumpto: Jump to, ccjumpby: Set the jump height and the number of ccbezierto: besell curve to and ccbezierby: besell Curve
Ii. Some modifier Classes 1. ccrepeat: Repeated execution times
local repeatAction = CCRepeat:actionWithAction(CCSequence:actionsWithArray(actions), 5)
2. ccrepeatforever: Permanent execution 3. ccsequence: sequential execution
local actions = CCArray:array()actions:addObject(CCFadeOut:actionWithDuration(1))actions:addObject(CCFadeIn:actionWithDuration(1))sprite:runAction(CCRepeatForever:actionWithAction(CCSequence:actionsWithArray(actions)))
4. ccspawn: run simultaneously
The final completion time of synchronization is determined by the time when the synchronization is completed in the basic action.
action1 = CCMoveTo:actionWithDuration(2, ccp(50, 50))action2 = CCRotateTo:actionWithDuration(2, 180)action3 = CCScaleTo:actionWithDuration(1, 4)action4 = CCScaleBy:actionWithDuration(1, 0)sequence = CCSequence:actions(action3, action4)sprite:runAction(CCSpawn:actions(action1, action2, sequence))
5. ccreversetime Reactionary Work
The formation of a loop, ccxxxto class usually does not support Reactionary Work, while ccxxxxby class usually supports
moveTo = CCMoveTo:actionWithDuration(2, ccp(50, 50))sequence = CCSequence:actions(moveTo,CCReverseTime:actionWithAction(moveTo))
6. ccanimate Animation
local action = CCAnimate:actionWithAnimation(animation)sprite:runAction(CCRepeat:actionWithAction(action, 10))
7. ccdelaytime delay wait class
action1 = CCMoveBy:actionWithDuration(1.2, ccp(200, 200))action2 = CCMoveBy:actionWithDuration(1.2, ccp(200, 200))sprite->runAction(CCSequence:actions(action1, CCDelayTime:actionWithDuration(1),action2))
8. ccprogressfromto and ccprogressto progress actions
The execution node of the Progress action is ccprogresstimer, rather than the common ccsprite
-- Time percentage to1 = ccprogressto: actionwithduration (2,100); lefttoright = ccprogresstation: progresswithfile (2017123.png ") hour: setscale (0.95) hour: setanchorpoint (ccpointmake (0.5, 0.5 )) lefttoright: setposition (Pt (winsize. width/) -- clockwise, counterclockwise, left, right, top, bottom (enumeration 0 1 2 ...) lefttoright: settype (type) lefttoright-> runaction (ccrepeatforever: actionwithaction (to1 ))
9. ccgridaction grid metrics class set
Grid action is a special conversion effect, similar to special effects, which can implement full screen, flip, jitter, shock, water ripple, etc.
Ccgridaction is the base class of all grid actions. It has two Derived classes,
Cctiledgrid3daction: tiled-based grid action, ccgrid3daction: normal grid action
3. Compensation animation (speed change)
Basic and composite actions enable various motion and animation effects for the genie, but their speed is usually constant
Through the ccactionease class and ccspeed class, we can easily change the speed at which the genie executes the action.
Cceasein-from slow to fast (linear speed change) cceaseout-from fast to slow cceaseinout-from slow to fast and then from fast to slow cceasesinein-from slow to fast (speed sine change) cceasesineout-from fast to slow cceasesineinout-from slow to fast and then from fast to slow cceaseexponentialin-from extremely slow (speed changes exponentially) cceaseexponentialout-from extremely fast to slow cceaseexponentialinout-from extremely slow to extremely fast and then from extremely fast to slow ccspeed-manually set the speed and can be continuously adjusted through setspeed