2

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?

bluestunt
  • 479
  • 4
  • 11

1 Answers1

5

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.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • Great! It's strange that it said this nowhere in any book or tutorial. – bluestunt Jan 12 '13 at 03:40
  • 4
    my book says so! ;) Chapter 9: "[…] all the built-in particle effects try to load a specific texture named fire.png, which is distributed with cocos2d-iphone in the Resources/Images folder. You can still create very good particle effects even without a texture, provided that the particle sizes remain fairly small. But to see the built-in particle effects as they were intended, you need to add the fire.png image to your Xcode project." – CodeSmile Jan 12 '13 at 13:41