Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocos2D - Particles follow the emitter instead of staying at the position they were released

In cocos2D I currently have a very simple particle emitter initialized like this:

    turnEmitter = [[CCParticleFlower alloc] init];
    turnEmitter.texture = [[CCTextureCache sharedTextureCache] addImage:@"Pocket.png"];
    [self addChild:turnEmitter z:1];
    turnEmitter.scale = 0.7f;
    turnEmitter.positionType = kCCPositionTypeFree;

It is simply added directly to the gameplay layer.

This emitter follows a sprite around the screen in this way (happens in the update method):

    turnEmitter.position = turnEmblem.position;

Now the problem is that the tail of particles left behind the emitter moves with the emitter, instead of released particles simply staying in the position they were released, which gives a really weird and stupid looking effect.

What I want to do is have the particles not follow the emitter at all after they have been spawned, unfortunately I have been unable to find any way of doing so.

As you can see from the code above I have already searched around, and found people which suggests changing the positionType property of the emitter, although I have tried all the possibilities and it does not solve the problem.

Does anyone have any ideas as to what this might be?

like image 742
CodingBeagle Avatar asked Apr 10 '12 17:04

CodingBeagle


1 Answers

You may want to try changing the "emitterMode" as well to "kCCPositionTypeFree". I had a similar issue where i had the emitter as a child of a CCNode. The CCNode was being rotated, but the particles and emitter wasn't. In the same way it looked stupid because the illusion of rotation was ruined. I need to set the following on my emitter:

emitter.emitterMode = kCCPositionTypeRelative;
emitter.positionType = kCCPositionTypeRelative;
like image 64
ezekielDFM Avatar answered Sep 30 '22 07:09

ezekielDFM