【发布时间】:2011-04-14 05:08:36
【问题描述】:
我正在制作崩溃的应用程序,并在控制台中给出上述警告。
有两个精灵。
Train=[CCSprite spriteWithFile:@"train.png"];
[self addChild:train z:0 tag:1];
AlphaImage=[CCSprite node];
AlphaImage.position=ccp(245,155);
[Train addChild:AlphaImage z:1 tag:2];
在其他方法中,我使用动画初始化 AlphaImage。
CCSpriteFrameCache *frameCache1 =[CCSpriteFrameCache sharedSpriteFrameCache];
[frameCache1 addSpriteFramesWithFile:plist1];
CCSpriteBatchNode *danceSheet1 = [CCSpriteBatchNode batchNodeWithFile:png1];
[self addChild:danceSheet1];
NSMutableArray *animFrames1 = [NSMutableArray arrayWithCapacity:frame[x]];
for(int i = 1; i < frame[x]+1; i++) {
NSString *namef1=[NSString stringWithFormat:@"%@%i.png",alpha1,i];
CCSpriteFrame *frame1 = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:namef1];
[animFrames1 addObject:frame1];
}
CCAnimation *anim1 = [CCAnimation animationWithFrames:animFrames1 delay:0.3f];
CCAnimate *animN1 = [CCAnimate actionWithAnimation:anim1];
CCRepeatForever *repeat1 = [CCRepeatForever actionWithAction:animN1];
[AlphaImage runAction:repeat1];
我已经使用 zwoptex 创建了 plist 和纹理图集。
随着火车的行驶和返回,用于动画更改的 plist 和纹理图集。但经过 4 或 5 次应用程序崩溃。在新动画出现在 AlphaImage 之前,我还处理了所有帧和纹理。我使用了这个:
[CCSpriteFrameCache purgeSharedSpriteFrameCache];
[CCTextureCache purgeSharedTextureCache];
我正在为应用程序使用高清图像。我浏览了许多文档,他们提出了这些建议:
[[CCSpriteFrameCache sharedSpriteFrameCache] removeSpriteFrames];
[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
但在控制台中,它没有显示任何关于使用这些行删除框架的信息。 有什么我做错了吗?
【问题讨论】:
标签: memory-management cocos2d-iphone didreceivememorywarning