I have the following problem in XNA: In one of my projects when I try to set the mouse position to (0,0) it moves the cursor outside the game window. If I get the mouse position and place the cursor in the top left corner it shows (170,0). What can be the problem? In another project if I try to set the mouse position in the constructor form my Game1 class it sets it outside the screen. However, if I set the position in the Update function it works fine. What should I do? Thanks in advance
1
votes
1 Answers
0
votes
The graphics device has not yet been set in the constructor of the game. I think that is your problem. So what i think is happening is you put the mouse at 0,0 of the default setting viewport in the game constructor. And once the graphics driver is set it offsets the mouse position.
If you need it before any of your code happens set it as the first thing in the Initialize method of Game1.cs.