Flint Particle System Forum - Change particles velocity wihtout change its direction 2016-06-02T18:32:41+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Change particles velocity wihtout change its direction http://flintparticles.org/forum/comments.php?DiscussionID=577&Focus=1972#Comment_1972 2012-11-06T17:10:28+00:00 2016-06-02T18:32:41+01:00 dfdiaza http://flintparticles.org/forum/account.php?u=638 This is my second day using Flint and I have a doubt. I have some particles moving inside a BoundingBox, but I need to have a Slider control, so I can change the particles velocity without change ... I have some particles moving inside a BoundingBox, but I need to have a Slider control, so I can change the particles velocity without change their directions.
I don't have idea how to achieve it. Can you help me please?

Regards,
Diego

Here is the current code with the particles inside a BoundingBox

import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.RadialDot;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;

var emitter:Emitter2D = new Emitter2D();
emitter.counter = new Blast( 10 );
var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
renderer.addEmitter( emitter );
addChild( renderer );






var moleculeGroup:InitializerGroup = new InitializerGroup();
moleculeGroup.addInitializer(new ImageClass(Asteroide) );

var bounds:Rectangle = new Asteroide().getBounds(this);
moleculeGroup.addInitializer(
new CollisionRadiusInit(
Math.max(bounds.width,
bounds.height)/2)
);


moleculeGroup.addInitializer(new Position( new RectangleZone( 150,150,300,300) ));
moleculeGroup.addInitializer(new Velocity( new PointZone( new Point( 100,100 ))));


emitter.addInitializer(moleculeGroup);
emitter.addAction( new Move() );
emitter.addAction(new Collide(1));
emitter.addAction(new BoundingBox(150,150,300,300))



emitter.start();

//TODO:
function changeSpeed()
{
how can I change the speed for all the particles from my emitter?
}]]>
Change particles velocity wihtout change its direction http://flintparticles.org/forum/comments.php?DiscussionID=577&Focus=1973#Comment_1973 2012-11-06T21:08:45+00:00 2016-06-02T18:32:41+01:00 dfdiaza http://flintparticles.org/forum/account.php?u=638 Never mind. I don't know if this is the correct way to achieve this, but I found a solution. for(var i=0;i
for(var i=0;i<emitter.particles.length;i++)
{
var p:Particle2D = Particle2D( emitter.particles[i] );
var loc:Point = new Point(velocity,velocity) // A point zone with my desired velocity.
if( p.rotation == 0 )
{
p.velX = loc.x;
p.velY = loc.y;
}
else
{
var sin:Number = Math.sin( p.rotation );
var cos:Number = Math.cos( p.rotation );
p.velX = cos * loc.x - sin * loc.y;
p.velY = cos * loc.y + sin * loc.x;
}
}]]>