Animation management in COCOS2D iphone.
Posted
by shreya
on Stack Overflow
See other posts from Stack Overflow
or by shreya
Published on 2010-03-29T09:49:51Z
Indexed on
2010/03/29
9:53 UTC
Read the original article
Hit count: 270
Hi All,
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.
© Stack Overflow or respective owner