Cocos2dx motion + rotation animation CCSequence CCAnimation CCAnimate CCMoveTo CCCallFuncN, cocos2dxccsequence

Source: Internet
Author: User

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)


Click here to view the full code

Related Article

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: 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.