I'm trying to modify Flash CS3's supplied fl.motion.easing.bounce
function to make the resulting animation bounce less. I appreciate that 'bounce less' is a bit vague, but I'd appreciate any help in understanding the function.
Thanks.
/**
* @param t Specifies the current time, between 0 and duration inclusive.
*
* @param b Specifies the initial value of the animation property.
*
* @param c Specifies the total change in the animation property.
*
* @param d Specifies the duration of the motion.
*
* @return The value of the interpolated property at the specified time.
*/
public static function easeOut(t:Number, b:Number,
c:Number, d:Number):Number
{
if ((t /= d) < (1 / 2.75))
return c * (7.5625 * t * t) + b;
else if (t < (2 / 2.75))
return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b;
else if (t < (2.5 / 2.75))
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b;
else
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b;
}
Basically, the function returns an interpolated value for the new position depending on 4 factors: current time of animation, initial value of the property being animated, total change of the animation to be done, and the total duration of the animation.
What you have there is a check for different timings: if the animation still didn't reach aprox 36% (1 / 2.75) of total duration, apply the first equation; if it's between 36% and 72%, apply the second; etc.
Every equation is a function depending on the first tree arguments, so basically you need to tweak them a little bit.
I'd suggest playing with that hard-coded 7.5625 (make it greater and lower to see the results) until you're satisfied.
The 7.5625
is Math.pow(2.75, 2);
, but hard-coded to save on processing.
I know this is not going to give you a clear cut answer either but these equations where first conceived by Robert Penner in his book Programing Macromedia Flash MX. I know it's not an easy answer, but in his book he explains in detail how these functions work. To really understand you might want to pick up a copy and dig in.
try to enlarge the first touch down time,and reduce the time of bouncing,I make first whole distance of 1.4/2.7, then 1.4~2.1,this range is 0.7,half range is 0.35,0.35*0.35=0.1225,1-0.1225=0.8775,that looks good,if you want to lower bouncing range,try to use this concept: decrease the range of two time point.
t /= d;
if (t < 1.4 / 2.75) {
return 3.858419 * t * t;
}
else if (t < 2.1 / 2.75) {
t -= 1.75f / 2.75;
return 7.5625 * t * t + 0.8775f;
}
else if (t < 2.5 / 2.75) {
t -= 2.3f / 2.75;
return 7.5625 * t * t + 0.96f;
}
t -= 2.625f / 2.75;
return 7.5625 * t * t + 0.984375f;