Mouse.SetPosition Method

Bb198868.note(en-US,XNAGameStudio.10).gifNote
This method is available only when developing for Windows.
Sets the position of the mouse cursor relative to the upper-left corner of the window.

Namespace: Microsoft.Xna.Framework.Input
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public static void SetPosition (
         int x,
         int y
)

Parameters

x
The horizontal position of the mouse cursor, relative to the left edge of the game window.
y
The vertical position of the mouse cursor, relative to the upper edge of the game window.

When using this method to take relative input, such as in a first-person game, set the position of the mouse to the center of your game window each frame. This will allow you to read mouse movement on both axes with the greatest amount of granularity.

Windows XP SP2, Windows Vista

Show: