Sprite Sheet Animation for Cocos2d-x v3

Sprite Sheet Animation for Cocos2d-x v3

Hi all,
I have looked for the cocos2d-x v3 tutorial from internet for a week, but will cant find a good tutorial that can teach me how to do the animation by using sprite sheet. >_<

I have done the plist and png by using texturePacker (please find the attached files), anyone can teach me to play the simple animation from the test.png ( the png included 11 images).

test-hd.plist.zip (0.7 KB)

test-hd.png (60.1 KB)

test.plist.zip (0.7 KB)

test.png (24.8 KB)

auto testBatchNode=SpriteBatchNode::create("test.png");
auto testSprite=Sprite::createWithSpriteFrameName("test1.png");
auto animation=Animation::create();
for(int i=1;i<=11;i++)
	char szName[100]={0};
testSprite->runAction( CCRepeatForever::create( CCAnimate::create(animation))); 

Hi libragagu,

It’s great! thanks a lot! thanks for your help!:slight_smile:

If you don’t mind, could you add my Skype:niccolohui?



Actually in the era of data oriented design composing frames into animation sequence directly in the code looks like a stone age.
There is the AnimationCache class which can load animations from the xml/plist-file. But I wonder which editor/tool can be used to create those files (googling did not help).

@niccolo You’re welcome,I’ve already sent a request to you.
I’m a beginner too,I hope we can learn from each other.:slight_smile:

@dotsquid Thank you, now I know another way to create animations.

AnimationCache *animationCache =AnimationCache::getInstance();
Animation* animation = animationCache->animationByName("Animation");

I wonder what does that plist file look like,and if it needs other data source files,I wonder what types are they(like png)?

ActionsTest.cpp and SpriteTest.cpp have examples of using AnimationCache. The plists used for the tests can be found here:


Hope that helps

Thank you!I’ve learnt many things today.
I still have two questions:
1.In the animations.plist file there are only sprite frame names


so I should add these frames to SpriteFrameCache before
am I right?

2.There isn’t any tool to create these files as @dotsquid said,is there?

1 Like

I believe you do need to add the frames to SpriteFrameCache before loading the animation plist.

I, unfortunately, do not know what tools might be available to create these animation plists. I did a little bit of googling and it seems like “SpriteHelper 2” might work, but the full version costs money and I haven’t tried out the trial version yet…

Unfortunately, Sprite Helper is for MacOSX only.

@libragagu My and your code to create sprite animation both gets executed successfully but all i can see is black screen. I have kept .plist file and png in resources folder. Where should i put it. What might be wrong here. Please help…M new to cocos2dx.