I've been working really hard for weeks now trying to get sprite sheet animation to work, and it isn't. I've tried, using this wiki page, http://www.cocos2d-x.org/wiki/Sprite_Sheet_Animation, and I've tried to make my own code, and neither have gotten e remotely close to where I want to be and I really have no idea what I'm doing here. Any help will be welcomed, and greatly appreciated. Thanks in advance.
1
votes
2 Answers
2
votes
For sprite sheet animation you have to make a plist for all your images.
Download texture packer : https://www.codeandweb.com/texturepacker
After installing the texture packer, add sprites to it and publish it.
It will create a plist. Add that plist and png to the resources folder of your project.
Now add the following code to the init() of your GameLayer :
SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("BowArrow.plist");
for (int i = 1; i <= 9; i++) {
frame = String::createWithFormat("Bow%d.png", i);
frames.pushBack(
SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(
frame->getCString()));
}
Now you have all the sprites of plist in a framecache and you can run animation on them in the way you want.
I hope it helps.