检查鼠标是否在游戏窗口内
我正在使用 XNA 在窗口中可视化 3D 场景(= 非全屏)。用户可以单击并拖动鼠标来移动相机:
Public Sub New()
...
Me.IsMouseVisible = True
Me.Window.AllowUserResizing = True
...
End Sub
Protected Overrides Sub Update(ByVal gameTime As Microsoft.Xna.Framework.GameTime)
Dim m = Mouse.GetState()
' Change camera position based on m
...
End Sub
这可行。问题是,当鼠标不在游戏窗口内时,这仍然有效,这看起来有点奇怪(我在 Outlook 中移动邮件,另一个窗口中的 3D 场景开始转动)。
我没有找到 Mouse.IsInsideGameWindow()
属性。我还能(轻松)做些什么来避免这种情况吗?
I'm using XNA to visualize a 3D scene in a window (= not full-screen). The user can click and drag the mouse to move the camera:
Public Sub New()
...
Me.IsMouseVisible = True
Me.Window.AllowUserResizing = True
...
End Sub
Protected Overrides Sub Update(ByVal gameTime As Microsoft.Xna.Framework.GameTime)
Dim m = Mouse.GetState()
' Change camera position based on m
...
End Sub
This works. The problem is that this even works when the mouse is not inside the game window, which looks a bit strange (I move a mail in Outlook and the 3D scene in the other window starts turning).
I didn't find a Mouse.IsInsideGameWindow()
property. Is there anything else that I can (easily) do to avoid this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)