Question

I have a sprite and a particle fire. Sprite is moving, so I want fire be at the same place as sprite all the time. That's what I tried. _abcdis the name of sprite.

CCParticleFire *emitter;
emitter = [CCParticleSystem particleWithFile:@"suchfire.particle"];
emitter.position=ccp(_abcd.position.x,_abcd.position.y);
[self addChild: emitter z:10];

When I run the game, fire is located in the lower left corner. Any ideas?

Était-ce utile?

La solution

Your sprite is moving after its position is assigned to the emitter. Remember that the position you're assigning to your emitter is not going to update with the movement of the sprite.

So the best way forward is to update the emitter's position as the position for the sprite updates. This can be done in your update method.

Or better yet apply whatever movement you're apply to your sprite, be it by the game or the user, to your emitter.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top