如何在c# XNA中设置光标的位置

Gle*_*654 2 c# xna position mouse-cursor

所以我对 XNA 还很陌生,但我已经弄清楚如何创建相机对象并控制它。我希望为我的相机提供一些更直观的控制,因为当光标使用以下代码击中屏幕边缘时,旋转就会停止。这有点不直观。

我希望能够将光标位置重置到屏幕中间,我该怎么做?

MouseState mouseState = Mouse.GetState();

yaw -= (mouseState.X - oldx) / 600.0f;
pitch -= (mouseState.Y - oldy) / 600.0f;

oldx = mouseState.X;
oldy = mouseState.Y;
Run Code Online (Sandbox Code Playgroud)

Asi*_*sik 5

要将鼠标位置设置为屏幕中间:

Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
Run Code Online (Sandbox Code Playgroud)

您可以在Riemers XNA 教程中查看相关示例。