开发者

Animation management in COCOS2D iphone

I have near about 255 image frames for background animation, 99 frames of enemy sprite and 125 frames of player sprite. All animations are running simultaneously on the screen. That is background animation is running and 4-5 enemies are on the screen are present at a time, also player is there at the same time.

Take a look at the code below,

CCAnimation *_enemyAnimation = [CCAnimation animationWithName:@"Enemy" delay:0.1f];
   for (int i = 1; i<99; i++) {
       [_enemyAnimation addFrameWithFilename:[NSString stringWithFormat:@"enemy %02d.jpg",i]];
   }

   id action1 = [CCAnimate actionWithAnimation: _enemyAnimation];
   [_enemySprite runAction:[CCRepeatForever actionWithAction: action1]];       
   [self schedule:@selector(BackToGameLogic:) interval:5.0];

This makes my game too slower and consumes memory about 65MB in the allocations.

How should I manage my animations so there will be improvement in speed and memory consumption will be开发者_运维百科 reduced?.

Please suggest me the way.

Thanks.


Make your animations out of a sprite sheet. Sprite sheets only call the buffer once per sheet, so you get a marked improvement over individual jpgs per frame.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜