I'm working on my first flash game, and I'm having trouble making a turret face the mouse in AS3.
The class file for the turret:
package
{
import flash.display.MovieClip;
import flash.events.Event;
public class Turret extends MovieClip
{
public function Turret()
{
x = 320;
y = 320;
addEventListener(Event.ENTER_FRAME, updateRotation)
}
public function updateRotation(evt:Event)
{
rotation = Math.atan2((mouseY - 320), (mouseX - 320)) * 180 / Math.PI;
}
}
}
It currently rotates like:
This
Any help would be greatly appreciated.