AS3:查找距离旋转 [英] AS3: Find distance of rotation
问题描述
我旋转我想的持续时间应以所述旋转的距离,其中180度= 3秒90 = 1.5等。
的对象TweenLite的,但是代替的一组持续时间下面是我试图寻找旋转的距离:
VAR时间:数= Math.abs(Math.atan2(Math.sin(角度wheelObj.rotation),Math.cos(角wheelObj.rotation));
TweenLite.to(wheelObj,时间,{shortRotation:{旋转:角度},方便:Expo.easeOut,的onComplete:rotateWheel,onCompleteParams:[目标]});
TweenLite.to(carObj,时间,{shortRotation:{旋转:角度},方便:Expo.easeOut});
这只是不工作,时间是旋转小,有时很小的时候就大,有时会很大,因此没有人知道一个更好的方式来做到这一点?
注:
角度
=目标转动
wheelObj.rotation
=当前旋转。
变种速度:数= 60; // 3秒,180度
VAR时间:数= Math.abs(角 - wheelObj.rotation)/速度;
您可以通过改变速度参数设定时间。
请注意:您可能需要使用的角度(角度%360)
I am rotating an object with TweenLite, however instead of a set duration I want the duration to be based upon the distance of rotation where 180 degrees = 3 seconds 90 = 1.5 and so on.
Here is my attempt to find the distance of rotation:
var time:Number = Math.abs(Math.atan2(Math.sin(angle-wheelObj.rotation),Math.cos(angle-wheelObj.rotation));
TweenLite.to(wheelObj, time, {shortRotation:{rotation:angle}, ease:Expo.easeOut, onComplete:rotateWheel, onCompleteParams:[target]});
TweenLite.to(carObj, time, {shortRotation:{rotation:angle}, ease:Expo.easeOut});
This just isn't working, time is sometimes huge when the rotation is small and sometimes tiny when it is big, so does anyone know a better way to do this?
Notes:
angle
= target rotation
wheelObj.rotation
= current rotation.
var speed:Number = 60; // 3 sec for 180 deg
var time:Number = Math.abs(angle - wheelObj.rotation) / speed;
You can set duration by changing speed parameter.
Note: You might need to use angle as (angle%360)
这篇关于AS3:查找距离旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!