AS2 - 数学过渡帮助
我在 Flash 中制作了一个下拉菜单,我希望它能够向下滑动。目前我使用线性幻灯片(_y += 5,_y -= 5)等。
我知道还有其他类型的转换,例如指数等,我将如何实现它们?我还记得曾经有一个网站使用不同的技术在 javascript 中展示了各种幻灯片动画。
im making a drop down menu in flash and i want it to slide down. At the moment im using a linear slide ( _y += 5, _y -= 5) etc.
I know there are other types of transitions like exponential and the like, how would i go about implementing them? I also remember there was a website once that showed all sorts of slide animations in javascript using different techniques.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个简单的幻灯片动画如下:
y = y*(1-speed) + (target_y)*(speed)
迭代导致框滑动,并在移动时减慢速度。速度应介于 0 和 1 之间。速度为 0.5 时,当前与目标之间的距离每时每刻都会减半。
或:
这会导致它加速,直到超出目标,然后停止。
作为
+ 0.1
的替代方案,您可以执行* 1.1
或类似的操作,从而引起指数运动,而不是二次运动。A simple slide animation would be:
y = y*(1-speed) + (target_y)*(speed)
Iterating that causes the box to slide, slowing down as it moves there. Speed should be between 0 and 1. With speed 0.5, the distance between the current and target would be halved every moment.
or:
Which causes it to accelerate until it goes beyond the target, where it stops.
As an alternative to
+ 0.1
, you could do* 1.1
or something similar, causing an exponential, rather than quadratic, motion.