Reputation: 49
private void Main_Step()
{
MouseState mouseState = Mouse.GetState();
double x_pixel, y_pixel;
device.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
spriteBatch.DrawString(testFont, "(" + mouseState.X + ", " + mouseState.Y, new Vector2(500, 50), Color.Yellow);
spriteBatch.End();
}
Whenever I excute XNA program, Even though I don't move mouse nothing, the mouse coordiante X, Y are continually chaging. I think it should be fixed because I didn't move mouse.
this problem makes mouse event hard.
what's the problem? My screen resolution is 1920 x 1080.
Upvotes: 1
Views: 162
Reputation: 5760
The MouseState.X and MouseState.Y represent the values of the mouse relative to the top-left corner of your window. The reason they're changing is probably because, in Windows, the window position changes every time you run the program. You could check if this is the case by taking screenshots each time you run.
Upvotes: 1
Reputation: 22123
MouseState.X and MouseState.Y are the coordinates of the mouse relative to the upper-left corner of the window. If they change, then that means either your window moves or your mouse moves. There's no other possible explanation.
Upvotes: 0