Reputation: 131
Here is my question:
I have a movieclip called player and i want to get his rotation;
player.rotation=0;
player.rotation-=90;
trace(player.rotation);//this traces -90, not 270
I would like to know why it dosent say the rotation is 270, because 0 is like 360 and when you rotate 90 degres left it should be 270;
I am asking this because it causes a problem in my game
Thanks
Upvotes: 0
Views: 6156
Reputation: 17217
-90 and 270 are different values, but a sprite with these values assigned to its rotation property will appear the same because rotation values for Display Objects do not have a limited range. from the documentation flash.display.DisplayObject.rotation:
Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement my_video.rotation = 450 is the same as my_video.rotation = 90.
if you want to limit this range you will have to create your own function to do so.
Upvotes: 3
Reputation: 39456
Rotation in Flash begins from the east and then increments up to 180 clockwise or decrements counter-clockwise down to -179.
For game development I recommend sticking to radians for any angular mathematics you need to do and using rotation
for display/rendering only.
Here is a small demo that outputs the rotation from 0 to 360 (0):
var shape:Shape = new Shape();
for(var i:int = 0; i<360; i++)
{
shape.rotation ++;
trace(shape.rotation);
}
You'll notice that the output clocks over to -179 after 180.
Upvotes: 1