Animating sprites in Cocos2d

Posted by Christian Budtz on Stack Overflow See other posts from Stack Overflow or by Christian Budtz
Published on 2010-04-14T11:49:58Z Indexed on 2010/04/14 11:53 UTC
Read the original article Hit count: 782

Filed under:
|
|

How do I avoid unneccesary deallocation? I'm running this code:

CCSpriteFrameCache * cache = [CCSpriteFrameCache sharedSpriteFrameCache];
    [cache addSpriteFramesWithFile:@"boosttexture.plist"];

    CCAnimation * animation = [[CCAnimation alloc] initWithName:@"boosting" delay:1/24.0f];

    [animation addFrame:[cache spriteFrameByName:@"ship.png"]];
    [animation addFrame:[cache spriteFrameByName:@"ship_boost_l_r.png"]];

    id action = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:animation]];
    [spaceShipSprite runAction:action];

When the animaton is running (granted - its an ugly one), I get this in the console:

2010-04-14 13:40:16.311 Booster2K10Beta[521:20b] cocos2d: deallocing CCSpriteFrame = 00EBA620 | TextureName=4, Rect = (1.00,32.00,32.00,32.00)

2010-04-14 13:40:16.411 Booster2K10Beta[521:20b] cocos2d: deallocing CCSpriteFrame = 00EBA620 | TextureName=4, Rect = (1.00,32.00,32.00,32.00)

2010-04-14 13:40:16.496 Booster2K10Beta[521:20b] cocos2d: deallocing CCSpriteFrame = 00EBA620 | TextureName=4, Rect = (1.00,32.00,32.00,32.00)

It seems unneccesary that the same SpriteFrame gets dealloc'ed 24 times per second - how do I avoid that?

© Stack Overflow or respective owner

Related posts about cocos2d-iphone

Related posts about sprites