Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to know how people usually save the animations in order to load them easily in Cocos2d with as few hard-code as possible.

E.G. The solution I thought of is to have one plist file containing information about each frame, and the second plist to contain information about each of the animation(name of the animation, which frames to play, and the delay probably).

If this is the correct solution, how can I generate such plist files for spritesheet automatically?

share|improve this question
2 that creates sprite sheets for you and you can export with a plist. There are a few more like zwoptex they are both good tool IMO – Savlon Apr 6 '13 at 20:20

This is the most basic code of creating and playing an animation in cocos2d:

auto cacher = SpriteFrameCache::getInstance();
Sprite* someSprite = Sprite::create();

// load all the animation frames into an array
Vector<SpriteFrame*> frames;
for (int i = 0; i <= 10; i++)
    stringstream ss;
    ss << "run_" << i << ".png";

// play the animation
Animation* anim = Animation::createWithSpriteFrames(frames, 0.05f);
someSprite->setPosition(X, Y);


And for creating some file like "emad-running.plist", I suggest Texture Packer. This tool support cocos2d fully. you can import your separated image, and Texture Packer give you two file:

  1. "emad-running.plist"
  2. "emad-running.pvr" OR "emad-running.png" OR ...

This two file complete each other and in code you just need to refer.plist and you are done. :)

This is how you do in TexturePacker:

Texture Packer Instruction

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.