Creating Frame Animation in Cocos2d-X 2.0 Using a Sprite Sheet

Saturday, July 28th, 2012

Since the Cocos2d-X 2.0 rc2 a lot of the initialisation has changed so this code works in Cocos2d-X 2.0.

First create a sprite sheet so we can load it in.

Once you have created the Sprite Sheet you will end up with a image file and plist.

mySprites.png
mySprites.plist

I like to name my sprites like this:

jumpAnimation_00
jumpAnimation_01
jumpAnimation_02
jumpAnimation_03
jumpAnimation_04
jumpAnimation_05

walkAnimations_00
walkAnimations_01
walkAnimations_02
walkAnimations_03
walkAnimations_04
walkAnimations_05

It makes creating the animations easier. My code below is depended on the above naming convention.

2 comments on “Creating Frame Animation in Cocos2d-X 2.0 Using a Sprite Sheet

  1. Nicson says:

    Good! could be please post how to apply this animation on multiple sprites, like gold coins , collectables ?

    • abe says:

      Since the sprite is a pointer you would need to create a class that generates a new instance when requested. When I have some time I will knock out a post with an example.

Leave a Reply

Your email address will not be published. Required fields are marked *