三角法を使用して距離と角度を計算し、ダイナミック テキスト ボックスに表示するゲームを作成しています。ムービー クリップの中心からカーソルまでの距離を計算しています。そして、ムービー クリップのその中心を使用して、カーソルが swf の周りを移動するときに、完全な 360 度を計算して表示しようとしています。ゲームの距離部分は機能していますが、度数を表示する部分が正しく機能していません。ダイナミック テキスト ボックスは、90 度から 270 度までしか表示されません。270º から 360º / 0º から 90º を超える代わりに、270º から 90º にカウントダウンします。以下は私のアクションスクリプトです。助けや提案をいただければ幸いです。ありがとう!
//Mouse and Dynamic Text Boxes-------------------------
Mouse.hide();
onMouseMove = function () {
feedback.text = "You are moving your mouse";
cursor._x = _xmouse;
cursor._y = _ymouse;
updateAfterEvent();
xmouse_value.text = Math.atan2((a), (b));
ymouse_value.text = Math.round(radians*180/Math.PI)
updateAfterEvent();
};
Mouse.addListener(myListener);
//distance (RANGE)
_root.onEnterFrame = function () {
xmid = Stage.width/2;
ymid = Stage.height/2;
a = _root._ymouse-ymid;
b = _root._xmouse-xmid;
c = Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2));
feedbacka.text = Math.round(a);
feedbackb.text = Math.round(b);
feedbackc.text = Math.round(c/30.4);
updateAfterEvent();
var radians:Number;
var degrees:Number;
//Calculcate Radians
//Radians specify an angle by measuring the length around the path of the circle.
radians = Math.atan2((c), (b))
//calculate degrees
//the angle the circle is in relation to the center point
//update text box inside circle
radians_txt = Math.round(radians*360/Math.PI);
degrees_txt = Math.round(radians*180/Math.PI);
updateAfterEvent();
//getting past 270 degrees
radians2_txt = Math.round(radians/Math.PI);
radians2_txt = Math.floor(radians + -270);
}