Animated sprites in Cocos2D

I have been working with Cocos2D for a while and I am still a newbie. The way to deal with animations in Cocos2D 1.0.0 – the stable version currently – is different from the way before using CCSpriteSheet. Now Cocos2D adapts animations as cache shared in the project using CCSpriteFrameCache. It also requires a plist file as well as a texture file.

First, put the following assets into the project “Resources” folder to let the program use.

grossini.plist – The file contain the animation information such as frame details.

// Run the sprite with the created animation and display it by adding it to the scene
[sprite runAction:[CCRepeatForever actionWithAction: [CCAnimate actionWithDuration:2.8f animation:animation restoreOriginalFrame:NO] ]];
[self addChild:sprite z:0];
[/sourcecode]

After all, don’t forget to deallocate the resources loaded in cache in function dealloc.