作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
这是一个广为人知的问题,有时甚至会出现在高预算的专业作品中,当您将窗口类型设置为“无边框” 并且您有如果鼠标不受限于当前运行游戏的显示器的限制,则鼠标可以“滑出屏幕”。
我想知道 LibGDX 如何解决这个问题。
是否有一些直接的方法来限制鼠标移动?
还是需要对鼠标位置做连续迭代计算之类的?
最佳答案
Libgdx 提供了在窗口内捕获鼠标光标的内置函数。您正在寻找的函数是 Gdx.input.setCursorCatched(true)。
取自文档:
void setCursorCatched(boolean catched) Only viable on the desktop. Will confine the mouse cursor location to the window and hide the mouse cursor. X and y coordinates are still reported as if the mouse was not catched. Parameters: catched - whether to catch or not to catch the mouse cursor
或者自己检查文档here .
关于java - 如何将鼠标光标限制在 LibGDX 的窗口范围内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24778054/
我是一名优秀的程序员,十分优秀!