1
我有一個對象,我需要通過點擊和拖動進行旋轉。在一些AS2代碼之後,每次單擊鼠標時都會讓對象旋轉一點,但無法使其與拖動一起工作。Actionscript 3,拖動時旋轉對象
needle.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
function fl_ClickToDrag_2(event:MouseEvent):void
{
var angle = Math.atan2(mouseY-needle.y,mouseX-needle.x);
// apply rotation to handle by converting angle into degrees
needle.rotation = angle*180/Math.PI;
// rotate the grip opposite the handle so it won't rotate along with it
//this.grip._rotation = -this._rotation;
}
function fl_ReleaseToDrop_2(event:MouseEvent):void
{
needle.stopDrag();
}
嗯,感謝它改進了一點bot不多。針頭MC卡入不同角度,不隨鼠標移動。當我點擊並拖動時,MC會捕捉到一個新的旋轉,如果我再將鼠標移動一些,它會捕捉到一個新的位置。它也只是順時針旋轉。 – RapsFan1981 2011-05-26 22:05:38
這可能與我的MC的輪換有關。該符號指向右側。 – RapsFan1981 2011-05-26 22:15:28
還沒有工作,不跟隨鼠標只能捕捉到一個新的角度。任何人? – RapsFan1981 2011-05-27 14:16:11