Flint Particle System Forum - Change direction2010-11-17T09:59:21+00:00http://flintparticles.org/forum/
Lussumo Vanilla & Feed Publisher
Change directionhttp://flintparticles.org/forum/comments.php?DiscussionID=59&Focus=282#Comment_2822008-07-28T16:24:11+01:002010-11-17T09:59:21+00:00simonhttp://flintparticles.org/forum/account.php?u=48
Hi All
Currently I have particles moving from one position to another
eg: emitter.addAction( new TweenPosition( 10, 10, 300, 300 ) );
however when the particles reach x:300, y:300 I would ...
Currently I have particles moving from one position to another
eg: emitter.addAction( new TweenPosition( 10, 10, 300, 300 ) );
however when the particles reach x:300, y:300 I would like them to curve and start in a new direction say to x:400, y:500
so I am basically creating a path for the particles to follow that looks fairly natural.
How would I go about doing this? Thanks for you help.
Cheers Simon]]>
Change directionhttp://flintparticles.org/forum/comments.php?DiscussionID=59&Focus=283#Comment_2832008-07-29T07:56:47+01:002010-11-17T09:59:21+00:00Richardhttp://flintparticles.org/forum/account.php?u=1
Hi Simon
Flint doesn't have an action for what you're trying to do, but fortunately it has been designed to make it easy to add additional functionality. You'll need to create a custom Action for ...
Flint doesn't have an action for what you're trying to do, but fortunately it has been designed to make it easy to add additional functionality. You'll need to create a custom Action for the movement you want and to use this custom action with your emitter. Actions are quite simple - extend the action class and implement your own new update method. Take a look at the code in the TweenPosition class for ideas and see how you get on.
Alternatively, do your animations need to be precise? Can you get the effect you want using physics? Specifically, using a number of Jets - these are accelerations that only operate in particular regions (called zones in Flint). So you could start with a Jet to apply an acceleration in a zone around the start point of the particles which pushes them towards the first target point, then add another Jet near this new point that pushes them towards the second target, and so on. It won't be as precise as using a tween but may look more natural, depending on what you're after.]]>
Change directionhttp://flintparticles.org/forum/comments.php?DiscussionID=59&Focus=284#Comment_2842008-07-29T09:35:06+01:002010-11-17T09:59:21+00:00simonhttp://flintparticles.org/forum/account.php?u=48
Thanks Richard
I'll try the jets first then creating a new actions class. Do you think it would be possible to use something like Tweener to control the particles? Then I could put in bezier ...
I'll try the jets first then creating a new actions class. Do you think it would be possible to use something like Tweener to control the particles? Then I could put in bezier ranges to create the curve effect in the correct places.
Cheers Simon]]>
Change directionhttp://flintparticles.org/forum/comments.php?DiscussionID=59&Focus=285#Comment_2852008-07-29T12:24:10+01:002010-11-17T09:59:21+00:00Richardhttp://flintparticles.org/forum/account.php?u=1
Yes, using Tweener should be possible.
Change directionhttp://flintparticles.org/forum/comments.php?DiscussionID=59&Focus=286#Comment_2862008-07-30T22:44:29+01:002010-11-17T09:59:21+00:00simonhttp://flintparticles.org/forum/account.php?u=48
I created a new Action class using Tweener, this worked well. The code is rough but pasted below for anyone interested.
----------------------------------------------------
package ...
----------------------------------------------------
/** * The TweenPosition action adjusts the particle's position between two * locations as it ages. This action * should be used in conjunction with the Age action. */
public class TweenTo extends Action { private var _diffX:Number; private var _endX:Number; private var _diffY:Number; private var _endY:Number; private var _speed:Number; private var _curvesArray:Array;
/** * The constructor creates a TweenPosition action for use by * an emitter. To add a TweenPosition to all particles created by an emitter, use the * emitter's addAction method. * * @see org.flintparticles.emitters.Emitter#addAction() * * @param startX The x value for the particle at the * start of its life. * @param startY The y value for the particle at the * start of its life. * @param endX The x value of the particle at the end of its * life. * @param endY The y value of the particle at the end of its * life. */ public function TweenTo( startX:Number, startY:Number, endX:Number, endY:Number, speed:Number, curvesArray:Array ) { _diffX = startX - endX; _endX = endX; _diffY = startY - endY; _endY = endY; _speed = speed; _curvesArray = curvesArray;
CurveModifiers.init();
}
/** * The x position for the particle at the start of its life. */ public function get startX():Number { return _endX + _diffX; } public function set startX( value:Number ):void { _diffX = value - _endX; }
/** * The X value for the particle at the end of its life. */ public function get endX():Number { return _endX; } public function set endX( value:Number ):void { _diffX = _endX + _diffX - value; _endX = value; }
/** * The y position for the particle at the start of its life. */ public function get startY():Number { return _endY + _diffY; } public function set startY( value:Number ):void { _diffY = value - _endY; }
/** * The y value for the particle at the end of its life. */ public function get endY():Number { return _endY; } public function set endY( value:Number ):void { _diffY = _endY + _diffY - value; _endY = value; }
/** * @inheritDoc */ override public function update( emitter:Emitter, particle:Particle, time:Number ):void {
} } }]]>
Change directionhttp://flintparticles.org/forum/comments.php?DiscussionID=59&Focus=288#Comment_2882008-07-31T07:23:12+01:002010-11-17T09:59:21+00:00Richardhttp://flintparticles.org/forum/account.php?u=1
Thanks Simon. That's very useful.
Change directionhttp://flintparticles.org/forum/comments.php?DiscussionID=59&Focus=289#Comment_2892008-07-31T13:57:44+01:002010-11-17T09:59:21+00:00chienhttp://flintparticles.org/forum/account.php?u=41
Simon,
I did something similar to what you are trying to do by creating a simple action which provides a way for an emitter to follow any object on the stage even those attached to a motion ...
I did something similar to what you are trying to do by creating a simple action which provides a way for an emitter to follow any object on the stage even those attached to a motion guide.