Cocos2dx motion + rotation animation CCSequence CCAnimation CCAnimate CCMoveTo CCCallFuncN, cocos2dxccsequence
Cocos2dx animation is amazing ~~, What we see here is an object that is constantly flipped during motion. Two animations come together ~~
The following code involves: CCAnimation (Compensation animation) CCAnimate (animation) CCDelayTime (delayed action) CCFadeTo (set transparent attitude) CCSequence (action sequence) CCSpawn (allows several animations of the genie to be executed simultaneously) CCRepeateForever (infinite loop) CCCallFuncN (node callback function in instantaneous action) CCMoveTo (mobile action)
It is written in lua, not in c ++. It is really good and convenient to write this by lua. Not to mention, read the code directly. The usage of these classes can be searched online.
Local winSize = CCDirector: sharedire(): getWinSize ()
Local layer = CCLayerColor: create (ccc4 (0, 0, 0,111), winSize. winSize, winSize. height)
-- Use a file to load texturepacker for an animation during the loading process -- this method is used to load images on the Internet. If you do not know the principle, google
Local cache = CCSpriteFrameCache: sharedSpriteFrameCache (): addSpriteFramesWithFile ("plist file ")
Local array = CCArray: create ()
For I = 1, n do -- Here n is the number of frames
Local path = string. format ("mongod.png", I)
Local name = CCSpriteFrameCache: sharedSpriteFrameCache (): spriteFrameByName (path)
Array: addObject (name)
End
Click here to view the full code