【问题标题】:How to set the cursor's position in c# XNA如何在 c# XNA 中设置光标的位置
【发布时间】:2012-04-21 23:52:34
【问题描述】:

所以我对 XNA 很陌生,但我已经知道如何创建一个相机对象并控制它。我想对我的相机进行一些更直观的控制,因为当光标使用以下代码击中屏幕边缘时,旋转停止。这有点不直观。

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

MouseState mouseState = Mouse.GetState();

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

oldx = mouseState.X;
oldy = mouseState.Y;

【问题讨论】:

    标签: c# position xna mouse-cursor


    【解决方案1】:

    将鼠标位置设置在屏幕中间:

    Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
    

    您可以在 Riemers XNA Tutorials 上查看此示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-23
      • 2012-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多