저는 삼각법을 사용하여 동적 텍스트 상자에서 거리와 각도를 계산하고 표시하는 게임을 만들고 있습니다. 나는 커서의 중심으로부터 커서의 거리를 계산하고있다. 그리고 그 무비 클립의 중심을 사용하여 swf 주위로 커서가 움직일 때 전체 360º를 계산하고 표시하려고합니다. 게임의 거리 부분이 작동하지만 각도가 표시된 부분이 제대로 작동하지 않습니다. 동적 텍스트 상자는 90º에서 270º까지만 표시됩니다. 270º에서 360º/0º에서 90º로 진행하는 대신, 270º에서 90º로 역행합니다. 아래는 나의 액션 스크립트입니다. 나는 어떤 도움이나 제안도 크게 감사 할 것입니다. 감사! atan2
에Actionscript 2와 Trigonometry를 사용하여 360도 전체를 어떻게 표시합니까?
//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);
}