5

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?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
CodingBeagle
  • 1,888
  • 2
  • 24
  • 52
  • "which gives a really weird and stupid looking effect" lol – Matisse VerDuyn Apr 10 '12 at 17:40
  • 1
    You're on the right track, changing the positionType should fix your problem, at least one of the positionTypes should. Are you sure you tried all of the options and tested each one? – CodeSmile Apr 10 '12 at 19:43
  • Hey :) Yes I'm pretty sure I've tried to use all possible options. Unfortunately I am not able to try it out currenty but will later today. I will report back with the exact properties I've tried then :) Thank you for taking the time to help! – CodingBeagle Apr 11 '12 at 09:05
  • Yes, I just found all the 3 possible property types in the Cocos2D source code, which are "kCCPositionTypeFree", "kCCPositionTypeRelative", and "kCCPositionTypeGrouped". TypeFree and TypeRelative didn't have any impact, while TypeGrouped just kept the particles grouped around the emitter instead of spreading them out. Now with TypeFree and TypeGrouped, the particles spawned will kind of stay behind the emitter as it moves, but they will still be repositioned relative to the emitter so it looks like the tail is following it in an odd way – CodingBeagle Apr 11 '12 at 11:26
  • while TypeFree really seems like it should make the particles totally independent of that emitter, which is clearly not happening. I'm not really sure what to do about this and have been stuck on it for a while now. – CodingBeagle Apr 11 '12 at 11:27
  • I encountered this problem too, I after digging the source code for a while, it seems that it is related with the scale, if the particle is scaled, the position updating code need consider the scale, otherwise, it will seems wired. – ocean Dec 24 '12 at 06:26

1 Answers1

8

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;
ezekielDFM
  • 1,947
  • 13
  • 26