cocos2d-iphoneccparticlesystemcctexturecache

CCParticleFire and CCParticleSystemQuad file not loading


I am trying to create particle effects like this:

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

I always get the following error:

    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 CCTextureCache

Does this means there is no image?


Solution

  • You have to add fire.png to your Xcode project, otherwise it can't be found by the app.

    The fire.png is located somewhere in the resources or tests folder of cocos2d.