Hello guys,
im in a little trouble here =)
Have tried so many times to make this cannon turning other side, looking for formulas, maths, physics, but nothing works until now. So, here im to ask you one more time.
My code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
easeTime = .5;
map.onRelease = function()
{
angle_ini = tank_mc.tank_gfx._rotation;
angle_end = Math.round(Math.atan2(tank_mc._ymouse, tank_mc._xmouse) * 180 / Math.PI);
new Tween(tank_mc.tank_gfx, "_rotation", Regular.easeIn, angle_ini, angle_end, easeTime, true);
}
What do this do? Simple, when click on the map, i get the current angle of the turret, and rotate it to the clicked angle.
Whats the problem? Flash… Always, the flash
Look the cartesian
|
|
Top left: -180
Top Right: 0
Bottom Left: 180
Bottom Right: 0
So, if the tank angle is 170º, and i click on the top left area (-170) instead he go the way up (171, 172, 173, … 179, 180, -179, -178, … -170) it is goes all the way wrong.
Not wrong, but the way that the tween suppose to go. I see the senocular pizza tutorial, but not solve my problem… Anothers rotation question is only “be” at new rotate, not the rotation itself…
Demo: http://www.fonix.com.br/main.swf
Thanks in advance