您好,对 LibGDX 有点新,目前在 PC 上的全屏模式有问题,我想要做的是在有人按下某个键时将我的游戏设置为全屏,并且每当我在主方法中输入内容时,这都不起作用桌面启动器.java。并且在核心映射中导入 LwjglApplicationConfiguration 类不起作用,因为它由于某种原因在那里不可用。
我在这个问题上测试了 PandaBR 提供的答案,它有效。 https://gamedev.stackexchange.com/a/119867/81956
把它放在你的主要 LibGDX / Game 类(不是 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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
648 次 |
| 最近记录: |