在每个场景的开头调用以下"清除"方法是一种好习惯吗?如果不是,我应该什么时候打电话给他们,是否有任何教程解释何时使用每个电话?我错过了什么吗?
[CCTextureCache purgeSharedTextureCache];
[CCSpriteFrameCache purgeSharedSpriteFrameCache];
[CCAnimationCache purgeSharedAnimationCache];
[CCShaderCache purgeSharedShaderCache];
[[CCFileUtils sharedFileUtils] purgeCachedEntries];
Run Code Online (Sandbox Code Playgroud)
(我正在使用Cocos2d 2.0并启用了ARC,不要认为它是相关的,但仍然认为值得一提)
memory-management cocos2d-iphone ios automatic-ref-counting cctexturecache
我正在尝试创建像这样的粒子效果:
emitter = [[CCParticleSystemQuad alloc] initWithTotalParticles:45];
[emitter setEmitterMode: kCCParticleModeGravity];
emitter.position = ccp(100, 100);
emitter.texture=[[CCTextureCache sharedTextureCache] addImage:@"fire.png"];
CCParticleFire *fire = [[CCParticleFire alloc]init];
fire.position = ccp(0,0);
[self addChild:fire];
[self addChild:emitter];
Run Code Online (Sandbox Code Playgroud)
我总是得到以下错误:
013-01-11 17:45:49.263 Jumpy[8945:c07] -[CCFileUtils fullPathFromRelativePath:resolutionType:] : cocos2d: Warning: File not found: fire.png
2013-01-11 17:45:49.264 Jumpy[8945:c07] cocos2d: CCTexture2D. Can't create Texture. cgImage is nil
2013-01-11 17:45:49.264 Jumpy[8945:c07] cocos2d: Couldn't add image:fire.png in CCTextureCache
2013-01-11 17:45:49.265 Jumpy[8945:c07] cocos2d: CCTexture2D. Can't create Texture. cgImage is nil
2013-01-11 17:45:49.265 Jumpy[8945:c07] cocos2d: Couldn't add image:fire.png in …Run Code Online (Sandbox Code Playgroud) ios ×1