Flint Particle System Forum - Using an easing for an own action Tue, 13 Dec 2011 00:11:05 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Using an easing for an own action http://flintparticles.org/forum/comments.php?DiscussionID=395&Focus=1338#Comment_1338 http://flintparticles.org/forum/comments.php?DiscussionID=395&Focus=1338#Comment_1338 Mon, 13 Sep 2010 10:00:42 +0100 radykal
For example I would like to move all a particles from the current position to another with easing:

I would use the time property as duration for the easing, but I dont know which property I can use for the counter. I could use an own one, but maybe you have a better solution.

override public function update(emitter:Emitter, particle:Particle, time:Number):void
{
var p:Particle2D = Particle2D(particle);
p.x = Cubic.easeOut(?????, currentX, targetX, time);

}
]]>
Using an easing for an own action http://flintparticles.org/forum/comments.php?DiscussionID=395&Focus=1353#Comment_1353 http://flintparticles.org/forum/comments.php?DiscussionID=395&Focus=1353#Comment_1353 Thu, 16 Sep 2010 08:37:13 +0100 Richard
package
{
class CustomAction extends ActionBase
{
public var effectDuration:Number;
public var targetX:Number;

public function CustomAction( target:Number, duration:Number )
{
targetX = target;
effectDuration = duration;
}

override public function update(emitter:Emitter, particle:Particle, time:Number):void
{
var p:Particle2D = Particle2D(particle);
if( !p.dictionary[this] )
{
p.dictionary[this] = {startX:p.x, distance:targetX - p.x, timePassed:0};
}
var state:Object = p.dictionary[this];
state.timePassed += time;
p.x = Cubic.easeOut(state.timePassed, state.startX, state.distance, effectDuration);
}
}
}


You store particle specific data in the particle's dictionary, initializing it if it'snot set. Then add the time to the particle's time passed on each update. ]]>
Using an easing for an own action http://flintparticles.org/forum/comments.php?DiscussionID=395&Focus=1360#Comment_1360 http://flintparticles.org/forum/comments.php?DiscussionID=395&Focus=1360#Comment_1360 Thu, 16 Sep 2010 13:06:30 +0100 radykal