Flint Particle System Forum - Using an easing for an own action 2011-12-13T00:29:35+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Using an easing for an own action http://flintparticles.org/forum/comments.php?DiscussionID=395&Focus=1338#Comment_1338 2010-09-13T10:00:42+01:00 2010-09-13T10:00:58+01:00 radykal http://flintparticles.org/forum/account.php?u=403 Currently I´m writing my own action and I would like to use a timeperiod easing (not an energyEasing) in the update method of the action. For example I would like to move all a particles from the ...
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 2010-09-16T08:37:13+01:00 2011-12-13T00:29:35+00:00 Richard http://flintparticles.org/forum/account.php?u=1 The time element is just the duration of this single frame. I doubt that's what you want. More likely you want the total time passed for the effect. Your custom action may be something like ...
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 2010-09-16T13:06:30+01:00 2011-12-13T00:29:35+00:00 radykal http://flintparticles.org/forum/account.php?u=403 You are awesome, I tried similar but didnt work for me. This works perfect. I already worked with the dictionary and saved the origin particle position in it.