开发者

Cocos2d SpriteSheet Animation

everywhere i lo开发者_Go百科ok i find code on how to run an animation using file created from zwoptex, but it is using deprecated code. I can't find code on how to run the animation using CCSpriteBatchNode.

Any suggestions?


This is the way I do animations using files created from zwoptex, but I am using CCSpriteFrameCache. I don't get any warnings, so I suppose this code is not deprecated:

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"frameSheet.plist"];
NSMutableArray* frames = [NSMutableArray array];
for(int i = 1; i <= numberOfFrames; ++i) {
    [frames addObject:
     [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"frame-%03d.png", i]]];
}
CCAnimation* anim = [CCAnimation animationWithFrames:frames delay:0.3f];

Texture file is named frameSheet.png, plist file is frameSheet.plist, and the composing images are named frame-001.png ... frame-100.png.

Let me know if this helps you.

EDIT:

strangely, for me animationWithFrames:frames is not deprecated:

Cocos2d SpriteSheet Animation

,

it says "from 0.99.5" and I have no issues with my animations...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜