我正在尝试修改 Flash CS3 提供的fl.motion.easing.bounce
函数使生成的动画弹跳更少。我知道“减少弹跳”有点模糊,但我希望能帮助您理解该功能。
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;
}
基本上,该函数根据 4 个因素返回新位置的插值:动画的当前时间、动画属性的初始值、要完成的动画的总更改以及动画的总持续时间。
您可以检查不同的时间:如果动画仍未达到总持续时间的约 36% (1 / 2.75),则应用第一个方程;如果在 36% 到 72% 之间,则应用第二个; ETC。
每个方程都是一个取决于第一个树参数的函数,所以基本上你需要稍微调整它们。
我建议使用硬编码的 7.5625(将其调大或调低以查看结果),直到您满意为止。
The 7.5625
is Math.pow(2.75, 2);
,但是硬编码以节省处理时间。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)