我目前正在研究一款釣魚遊戲中的功率計,其中用戶鼠標輸入決定了量表的垂直功率,有一個容器矩形MC和一個長度爲1的儀表矩形,根據mouseStart事件和mouseMove事件計算出的差異調整儀表高度,是否有更好的計算方法?因爲目前略有不同會導致電錶中出現大的「跳躍」。功率計量表動畫
杆的功能。
private function touchStarted(evt:MouseEvent):void
{
startY = evt.stageY;
}
private function rotateTurret(evt:MouseEvent):void
{
trace("rot "+rotation);
endY = evt.stageY;
if (startY != 0)
{
difference = startY-endY ;
txt.text = difference.toString();
_powerMeter.increment(difference);
}
}
功率計功能
private function loop(e:Event):void
{
fill.height += _diff;
if (fill.height >= 200)
fill.height = 200;
if (fill.height < 0)
fill.height = 0;
}
public function increment(value:Number):void
{
_diff = value;
}
循環在功能類的enterFrame中被調用。 – sutoL