在处理鼠标和键盘事件之前,确保我的XNA游戏具有焦点 [英] Making sure my XNA game has focus before handling mouse and keyboard events

查看:127
本文介绍了在处理鼠标和键盘事件之前,确保我的XNA游戏具有焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个混合了winforms的游戏(对于地图编辑器)。我面对的问题是,即使主游戏窗口不在焦点,它仍然收到鼠标变化事件(如点击和移动鼠标)。

有没有办法确保我的应用程序在焦点之前继续处理这些事件是否有一些内置的方法?

谢谢!

解决方案使用 Game.IsActive 属性检查是否应该处理鼠标和键盘输入。

I'm developing a game that is mixed with winforms (for the map editor). The problem I am facing is that even if the main game window isn't in focus, it still receives mouse change events (such as clicking and moving the mouse).

Is there a way to make sure my application is in focus before continuing on to handle these events are is there some kind of built in method?

Thanks!

解决方案

Use the Game.IsActive property to check if you should deal with mouse and keyboard input.

这篇关于在处理鼠标和键盘事件之前,确保我的XNA游戏具有焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆