Looking good, but i have a problem!

Yup. I need the player, at a constant coordinate of 400, 300, to face the mouse. And i suck at stuff like this? Any help?

rotation degrees = 0 when facing right. Up is 270. ect…

Comments

delpes
17. Dec 2011 · 13:18 UTC
float radiansToMouse = (float) Math.atan2(400 – input.getMouseX(), 300 – input.getMouseY());

float degreesToMouse = (57.2957795f * radiansToMouse) * -1;

heroImage.setRotation(degreesToMouse);
17. Dec 2011 · 13:26 UTC
Yes, thanks! You saved my day!