如何在 LibGDX 中按键时启用全屏
How to enable fullscreen when pressing a key in LibGDX
你好 LibGDX 有点新,目前在 PC 上的全屏模式有问题,我想做的是在有人按下某个键时将我的游戏设置为全屏,但这没有任何作用每当我在 desktopLauncher.java 的主要方法中键入内容时。在核心映射中导入 LwjglApplicationConfiguration class 不起作用,因为由于某种原因它在那里不可用。
我测试了 PandaBR 提供的关于这个问题的答案,它有效。
https://gamedev.stackexchange.com/a/119867/81956
将其放入主 LibGDX / 游戏 class(不是 DesktopLauncher)的渲染方法中。将 "Input.Keys.TAB" 更改为您要切换程序进入和退出全屏模式的键。
if (Gdx.input.isKeyPressed(Input.Keys.TAB)){
Boolean fullScreen = Gdx.graphics.isFullscreen();
Graphics.DisplayMode currentMode = Gdx.graphics.getDisplayMode();
if (fullScreen == true)
Gdx.graphics.setWindowedMode(currentMode.width, currentMode.height);
else
Gdx.graphics.setFullscreenMode(currentMode);
}
你好 LibGDX 有点新,目前在 PC 上的全屏模式有问题,我想做的是在有人按下某个键时将我的游戏设置为全屏,但这没有任何作用每当我在 desktopLauncher.java 的主要方法中键入内容时。在核心映射中导入 LwjglApplicationConfiguration class 不起作用,因为由于某种原因它在那里不可用。
我测试了 PandaBR 提供的关于这个问题的答案,它有效。 https://gamedev.stackexchange.com/a/119867/81956
将其放入主 LibGDX / 游戏 class(不是 DesktopLauncher)的渲染方法中。将 "Input.Keys.TAB" 更改为您要切换程序进入和退出全屏模式的键。
if (Gdx.input.isKeyPressed(Input.Keys.TAB)){
Boolean fullScreen = Gdx.graphics.isFullscreen();
Graphics.DisplayMode currentMode = Gdx.graphics.getDisplayMode();
if (fullScreen == true)
Gdx.graphics.setWindowedMode(currentMode.width, currentMode.height);
else
Gdx.graphics.setFullscreenMode(currentMode);
}