Flint Particle System Forum - Change Initializer after Particles are generated2011-06-23T13:21:02+01:00http://flintparticles.org/forum/
Lussumo Vanilla & Feed Publisher
Change Initializer after Particles are generatedhttp://flintparticles.org/forum/comments.php?DiscussionID=226&Focus=825#Comment_8252009-06-23T05:51:58+01:002009-06-23T05:55:15+01:00krankehttp://flintparticles.org/forum/account.php?u=214
Dear Richard, Thank you so much for a wonderful framework.
I need to know if I can modify the initializers after the emitter is generated. For example I need a bunch of floating particles to come ...
I need to know if I can modify the initializers after the emitter is generated. For example I need a bunch of floating particles to come together to form a line of text (in shape), then fade the matching bitmap text right on top. Next to expand again and back to another line of text and so forth.
So I have something like this public function CloudEmitter(stage:DisplayObject) { motaLogo = Bitmap(new Mota()).bitmapData; counter = new Blast(300); motaParticles = new InitializerGroup(); motaParticles.addInitializer(new PV3DObjectClass(Particle, null, 4)); motaParticles.addInitializer(new MassInit(1)); motaParticles.addInitializer(new CollisionRadiusInit(2)); motaParticles.addInitializer(new ApplyMaterial(ParticleMaterial, 0xFFFFFFFF, 0, ParticleMaterial.SHAPE_CIRCLE)); motaParticles.addInitializer(new ColorInit(0xFF6600FF, 0xff4455FF));
motaParticles.addInitializer(new Position(new BoxZone(280, 280, 280, new Vector3D(0, 0, 0), new Vector3D(1, 1,1), new Vector3D(2, 2, 1)))); motaParticles.addInitializer(new Velocity(new SphereZone(new Vector3D(0, 0, 0), 10, 10)));
private function setToHeadline1():void { motaParticles.addInitializer(new Position(new BitmapDataZone(motaLogo,new Vector3D(0, 0, 0), new Vector3D(180, 0, 0),new Vector3D(0, 90, 0)))); }
Where function setToHeadline is my text line, see I can actually have either or. I really need to be able to animate from one to another.
Please help.]]>
Change Initializer after Particles are generatedhttp://flintparticles.org/forum/comments.php?DiscussionID=226&Focus=826#Comment_8262009-06-23T12:19:39+01:002009-06-23T12:20:36+01:00SanMajohttp://flintparticles.org/forum/account.php?u=213
you have to save the Position initializer as an variable for CloudEmitter, than you can change its value any time and the emitter reflects those changes:
public function ...
public function CloudEmitter(stage:DisplayObject) { private var motaPosition:Position = new Position(new BoxZone(280, 280, 280, new Vector3D(0, 0, 0), new Vector3D(1, 1,1), new Vector3D(2, 2, 1)));
...
// and later: private function setToHeadline1():void { motaPosition.zone = new BitmapDataZone(motaLogo,new Vector3D(0, 0, 0), new Vector3D(180, 0, 0),new Vector3D(0, 90, 0)); }
This will not solve your problem with tweening particles from one position to another but this is a better way to change initializers after the emitter started.
I dont know if there is an easier solution for your problem but you could look at: org.flintparticles.threeD.actions.TweenPosition - With that you could tween (move) the particles between two Vectors (but you would have to set it for every particle) org.flintparticles.threeD.actions.ZonedAction - With this you could add friction to the particles only if they are within the specified zone (for example your bmp text) this could create an effect of particles swirling around your text and stick on it if they hover above it.
there are many solutions to your problem, but you have to try some to choose which looks best.
kind regards]]>
Change Initializer after Particles are generatedhttp://flintparticles.org/forum/comments.php?DiscussionID=226&Focus=829#Comment_8292009-06-23T18:36:45+01:002009-06-23T18:38:44+01:00krankehttp://flintparticles.org/forum/account.php?u=214
SanMajo
Thank you much for your prompt response, it seems that the answer still eludes me. I tried the changes you suggested to not avail. Try hitting shift key and nothing man... Note that I am ...
Thank you much for your prompt response, it seems that the answer still eludes me. I tried the changes you suggested to not avail. Try hitting shift key and nothing man... Note that I am instantiating this as an emitter in my main class.
Here is the new code
private var motaPosition:Position;
public function CloudEmitter(stage:DisplayObject) {
counter = new Blast(300);
motaLogo = Bitmap(new Mota()).bitmapData; motaPosition = new Position(new BoxZone(280, 280, 280, new Point3D(0, 0, 0), new Vector3D(1, 1, 1), new Vector3D(2, 2, 1)));
// Click shift to change position initializer stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener, false, 0, true); }
private function keyDownListener(ev:KeyboardEvent):void { if (motaParticles && ev.keyCode == Keyboard.SHIFT) { setToHeadline1(); } }
public function setToHeadline1():void { motaPosition.zone = new BitmapDataZone(motaLogo, new Point3D(0, 0, 0), new Vector3D(180, 0, 0), new Vector3D(0, 90, 0)); trace("Not working still?") }]]>
Change Initializer after Particles are generatedhttp://flintparticles.org/forum/comments.php?DiscussionID=226&Focus=836#Comment_8362009-06-24T21:33:35+01:002011-06-23T13:21:02+01:00SanMajohttp://flintparticles.org/forum/account.php?u=213
hi kranke!
im sorry if i confused you with my answer ;-)
The above code cannot work like you expect because initializers only influence particles that are created after they were set!
you are ...
im sorry if i confused you with my answer ;-) The above code cannot work like you expect because initializers only influence particles that are created after they were set! you are creating particles with a blast counter -> so you cant influence them afterward! thats only possible with actions
i only wanted to show you how you could in general change initializers after an emitter has started.
My real answer to your problem were the second thoughts: org.flintparticles.threeD.actions.TweenPosition - With that you could tween (move) the particles between two Vectors (but you would have to set it for every particle) org.flintparticles.threeD.actions.ZonedAction - With this you could add friction to the particles only if they are within the specified zone (for example your bmp text) this could create an effect of particles swirling around your text and stick on it if they hover above it.
kind regards]]>
Change Initializer after Particles are generatedhttp://flintparticles.org/forum/comments.php?DiscussionID=226&Focus=837#Comment_8372009-06-25T02:46:34+01:002011-06-23T13:21:02+01:00krankehttp://flintparticles.org/forum/account.php?u=214
No worries, thanks for taking the time to reply.
Ok, I think TweenPosition will work great, when you say set it for every particle I should do a for each loop right?
Question: could I add an ...
Ok, I think TweenPosition will work great, when you say set it for every particle I should do a for each loop right?
Question: could I add an explosion to my Emmiter then use removeAction to put it back the way it was?
I tried putting the action as such and nothing
emitter.start();
explode = new Explosion(500, new Point3D(0, 0, 0), 500, 20);
addEventListener(Event.ENTER_FRAME, render); // Click shift to change position initializer stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener, false, 0, true); stage.addEventListener(KeyboardEvent.KEY_UP, keyUpListener, false, 0, true); }
So removing the action is not working as intended?
Sorry for many questions, I hope there is an answer...]]>
Change Initializer after Particles are generatedhttp://flintparticles.org/forum/comments.php?DiscussionID=226&Focus=838#Comment_8382009-06-25T08:09:35+01:002009-06-25T08:12:05+01:00Richardhttp://flintparticles.org/forum/account.php?u=1
Hi kranke
To be clear, as SanMajo said, Initializers only affect particles when they are created. Once a particle has been created, no ampount of tinkering with initializers will affect ...
To be clear, as SanMajo said, Initializers only affect particles when they are created. Once a particle has been created, no ampount of tinkering with initializers will affect it.
Actions affect particles every frame. However, the effect that actions have had on the particles cannot be undone by removing the action. Removing the action simply prevents it affecting the particles in the future.
You have two options.
1. Use one or more actions to pull the particles towards the text, then stop them when they reach the text. To pull the particles towards the text you might try GravityWell. To stop them when they reach the text (use contains() on a BitmapDataZone to find if they're inside the bitmap), you could set their velocity to zero and add a very high friction, or something like that.
2. I think a better option, but perhaps not so easy, is to write a custom action. Look in the TweenPosition action and try altering it to your needs. The target of the tween (endX, endY) should be a custom value for each particle (store the target values inside each particle's dictionary), and use getLocation() on a BitmapDataZone to get this target. You'll also want to manage the duration of the tween independently - the current tween bases it's duration on the lifetime of the particle, which means it that the particle will die when the tween completes, and you don't want that to happen. If you get the action right, adding it to the emitter will cause all your particles to move to points within the bitmap.]]>