I’ve been having some trouble getting a sprite to animate, which is a huge problem as the game I’m making relies heavily on animated sprites. I’ve been working from this example (http://gamedev.stackexchange.com/questions/25513/how-to-play-animations-in-cocos2d-x) but I’ve noticed that most of the methods are now deprecated so I’ve amended where necessary.
Here is my code for setting up the animation:-
@ CCArray *FrameArray = CCArray::create();
//Create an Animation Object
m_pGruntAnimation = CCAnimation::create;
//Set up new sprite to add animation to
CCSprite *spriteAnim = CCSprite::create~~>spriteFrameByName);
//create the animate action and set up parameters
CCAnimate animate = CCAnimate::create;
//Repeat animation forever
CCActionact = CCRepeatForever::create;
//Run the action
//Attach new sprite to parent
m_pObjectsSprite~~>addChild(spriteAnim, 5, 0);@
All this code does is add a child sprite to the parent but it does not animate ever.
Can anyone point out where I’m going wrong, what I’m missing out or offer an alternative?