Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图通过调用鼠标类并使用 GetState 方法来获取光标的位置,但返回值始终为 0,0。我到处搜索,所有代码在其他示例中看起来都一样。我尝试了其他声明类的方法,但得到了相同的结果。
public void Update() { var ms = Mouse.GetState(); cursorPos = new Vector2(ms.X, ms.y); }
如果您使用的是 Mono,则该Mouse.GetState方法可能会被扩展。在过去的一些版本中存在问题的Mouse.SetState方法,可能也是问题也在Mouse.GetState......所以我建议你采用最新的 Mono 框架。
Mouse.GetState
Mouse.SetState
或者您可以尝试直接访问该方法。
var ms = Microsoft.Xna.Framework.Input.Mouse.GetState(); var mp = new Point(ms.X, ms.Y);