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