it looks like on the wiki and on a couple of other places that using a CCSpriteBatchNode to animate a single sprite is an appropriate action. For me this raises concerns as I have several unique animations going on and having several CCSpriteBatchNodes just to animate each one seems like a waste of resources. (see: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Animations )
In the past when I was animating in UIKit it was useful enough to load a single png at a time, display, then release to load the next PNG. actually the result was extremely fluid in animation even for multiple objects on screen. That being said I understand the appeal of a sprite sheet so i’m adopting it here.
Couldn’t I just do something like this though?
CCTexture2D* spriteSheet = //load sprite sheet code
CCSpriteFrame* firstFrame = //get first frame of sprite
CCSprite* animatedSprite = CCSprite::createWithTexture;
The idea being here that although it is a single animated sprite, it doesn’t need to animate until the user touches it.
Okay so definitely got this to work. interesting though that there wasn’t a single example I could find that didn’t include SpriteBatchNode. here’s what i did, and it works great:
First I subclassed CCSprite and put this in the Iint.
char const* textureSheetName = “spriteName.plist”
char const* firstFrame = helperThingIWrote~~>getFirstFrameName;
later when i wanted to animate a file i used a helper method i wrote to give me all the frames, then assign them to an animation
CCArray* flipFrames = m_donut~~>getFlipFrames();
CCAnimation* animation = CCAnimation::createWithSpriteFrames(flipFrames, 1 / 30.0f);
when i wanted the animation to play in reverse, turns out that’s quite easy!
this~~>runAction( CCAnimate::create(animation)~~>reverse );
This is easy stuff i know, but it just wasn’t documented anywhere, and the only “animation” example was using SpriteBatchNode. When the framework hits 3.0 I’ll update the wiki :~~P