I am developing an XNA game. I run it in window mode.
I need to handle mouse events, but when I use the Mouse
class from Xna.Framework.Input.Mouse
, I get the the mouse position on the whole screen.
I use this code:
MouseState state = Mouse.getState();
Point position = new Point(state.X,state.Y);
Rectangle hitbox = new Rectangle(180, 410, 14, 14);
if (area.Contains(mousePosition))
{
//fire event
}
How do I detect the mouse position within the current game window?
Mouse.getState()
is updated even when the application is stopped. \$\endgroup\$