Hello all,
I'm having some problems achieving a particle effect,
I wonder if anyone can point me to the right solution.
First off, I'm using Cocos2D + Chipmunk.
I have a ball as the player character, and 3 control buttons (up, left, right).
The player can fly around the stage with the controls, and falls ball down if nothing is pressed.
I want to give some bursts of energy when the user uses the controls, so when the user presses Up, a jet of particles bursts from the bottom (I use a scaled-down "meteor" preset), and when the user presses left or right, a jet of particles will burst from the opposite side.
Now, I was able to do it, but the movement looks weird.
My emitter setup is this:
emitter = [CCParticleMeteor node];
emitter.position = ccp(200, 70);
emitter.scale = 0.2f;
emitter.speed = 10;
emitter.rotation = 0;
emitter.gravity = ccp(0,-300);
emitter.emissionRate = 200;
emitter.positionType = kPositionTypeFree;
emitter.autoRemoveOnFinish = YES;
emitter.blendAdditive = YES;
emitter.life = 0.5f;
emitter.startSize = 50.0f;
emitter.endSize = 0.0f;
emitter.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.pvr"];
[self addChild: emitter z:10];
I've tried several methods I could think of to achieve the bursts,
I tried to change the emitter.rotation value on press, but it also rotates the already-emitted particles. They don't continue in their expected path, they get rotated with the emitter.
I tried to change the emitter.angle value, but it seems to have the same effect.
I tried to change the emitter.gravity value, it gave the best results, but still looks weird.
Those methods also have 2 big flaws: The already-emitted particles somehow follow the moving emitter (it always follow the player's sprite), and the emitter needs to be placed at the center of the sprite.
I tried another method where I change the position of the emitter. When the user presses Up, the emitter is moved to the bottom of the sprite and shoots down. When Right or Left is pressed, the emitter is moved to the correct side of the ball's sprite and shoots sideways.
But with this method, when I move the emitter, all of the already-emitted particles also jump to the new position.
So, I basically have 3 questions:
1. is there a way to make the particles not to follow the emitter?
2. is there a way to move/rotate the emitter without it affecting the already-emitted particles? Do I need to use 3 different emitters?
3. how can I stop the emitter and resume it?
Thank you!