0
我需要根据鼠标拖动使MovieClip围绕其中心点向左或向右旋转。我得到了一些我想要的东西的基本表象,但它很骇人听闻。通常我会计算角度等,但我只需要使用鼠标移动的距离并将其应用到动画片段,并且在放手时添加一些很好的缓动。在ActionScript中拖动,旋转和放松
public function Main()
{
var wereld:MainScreen = new MainScreen();
addChild(wereld);
wereld.x = -510;
planet = wereld["planet"];
wereld.addEventListener(MouseEvent.MOUSE_DOWN, startRotatingWorld);
}
private function startRotatingWorld(e:MouseEvent):void
{
m_mouseStartPos = stage.mouseX;
stage.addEventListener(MouseEvent.MOUSE_UP, stopRotatingWorld);
stage.addEventListener(Event.MOUSE_LEAVE, stopRotatingWorld);
}
private function applyRotationToWorld(e:MouseEvent):void
{
//Calculate the rotation
var distance:Number = (m_mouseStartPos - stage.mouseX)/10000;
//apply rotation
planet.rotation += -distance //* 180/Math.PI;
}
private function stopRotatingWorld():void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, applyRotationToWorld);
}
我发现了另一个我实现的解决方案。如果你想我可以展示给你。然而,你的答案是相当不错的,因为你的解决方案,所以我会把它设置为解决:) – Zophiel