在Cocos2d中动画精灵

时间:2010-04-14 11:49:59

标签: animation cocos2d-iphone sprite

如何避免不必要的释放?我正在运行此代码:

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];

当动画片正在运行时(被授予 - 这是一个丑陋的动画片),我在控制台中得到了这个:

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)

似乎不必要的是,同一个SpriteFrame每秒被释放24次 - 我该如何避免?

1 个答案:

答案 0 :(得分:1)

我假设你将CCDEBUG调高到2.把它放回到1.这是你看到的CCLOGINFO的东西。仍然,使用Xcode的分析工具来查看内存是否正在耗尽。我打赌不是。你只是看到了你还不了解的东西。