September 2014
Beginner
266 pages
5h 38m
English
Now that we have the files ready to animate, let's first create a simple animation loop. Later, we will see how to go from one animation to another depending upon the player state.
First, let's just play the idle animation.
In the HelloWorldScene.cpp file, right after you added the player to the display list, type the following code:
//player animation CCSpriteBatchNode* spritebatch = CCSpriteBatchNode::create("player_anim.png"); CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache(); cache->addSpriteFramesWithFile("player_anim.plist"); hero->createWithSpriteFrameName("player_idle_1.png"); hero->addChild(spritebatch); //idle animation CCArray* animFrames = CCArray::createWithCapacity(4); char str1[100] ...Read now
Unlock full access