Page 2 of 2

Re: mouse direction

Posted: Thu Oct 31, 2013 10:41 am
by DaedalusYoung
You compare mouse.x with player.x, but they could both be using a different scale. Especially if you have a camera lib that changes the coordinate system, then player.x could be somewhere very high, say 2000 pixels, while the mouse coordinates are always somewhere inbetween 0 and, for example, 800. Clicking on coordinate 800 will make the game think you're clicking on the left side, not right. You'll need to convert the player's coordinates to the same values the mouse is using before you can compare them.