-
Dance Monkey Dance!
Quick question
Hey guys,
Just wondering if someone could help me out with a formula for easing out. I can ease in fine but I'm confused on how to ease out.
I'm trying to get an object to move towards a point by speeding up and stopping at the point.
So origin_x is 10 and destination_x is 200, so its last x step should be its fastest before it stops?
Thanks
"I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"
-
looks like you're actually trying to do ease in...
you can use exponential interpolation:
PHP Code:
function easeIn( begin:Number, end:Number, t:Number, power:Number = 5 ) : Number { return begin + ( end - begin ) * Math.pow( t, power ); }
where begin is your original value, end your target value, t is a value 0 <= t <= 1 that represents the percentage through the animation time. the higher the power the slower the acceleration and the faster the end speed.
Last edited by newblack; 05-27-2010 at 01:31 PM.
-
Dance Monkey Dance!
Thanks newblack. One question about the t variable. Do I increment it every time the function is called
time = 0;
thing.x = easeIn(0, 200, time);
time++;
"I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"
-
you want it to be currentTime / duration, so when the animation starts, t = 0, and at the end it's equal to 1.
-
Dance Monkey Dance!
Ahh I see understood. Works a treat. Thanks heaps for your help newblack.
"I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|