gpt4 book ai didi

java - 如何将鼠标光标限制在 LibGDX 的窗口范围内?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:13:01 25 4
gpt4 key购买 nike

这是一个广为人知的问题,有时甚至会出现在高预算的专业作品中,当您将窗口类型设置为“无边框” 并且您有如果鼠标不受限于当前运行游戏的显示器的限制,则鼠标可以“滑出屏幕”。

我想知道 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com