我想知道如何在启动时使我的桌面应用程序全屏。我对LibGDX不熟悉,非常感谢任何帮助。谢谢。
我想知道如何在启动时使我的桌面应用程序全屏。我对LibGDX不熟悉,非常感谢任何帮助。谢谢。
只需在您的 LwjglApplicationConfiguration
中定义 fullscreen
字段:
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "yourGame";
cfg.width = 1024;
cfg.height = 768;
cfg.fullscreen = true;
new LwjglApplication(new ...(), cfg);
如果您想以全屏模式启动游戏,请在桌面启动器的LwjglApplicationConfiguration中设置以下标志(即main()函数):
public static void main(String[] args) {
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.width = 1280;
cfg.height = 720;
// fullscreen
cfg.fullscreen = true;
// vSync
cfg.vSyncEnabled = true;
new LwjglApplication(new YourApplicationListener(), cfg);
}
如果您想在游戏中启用任何分辨率或桌面默认的全屏选项,请使用以下方法:
// set resolution to HD ready (1280 x 720) and set full-screen to true
Gdx.graphics.setDisplayMode(1280, 720, true);
// set resolution to default and set full-screen to true
Gdx.graphics.setDisplayMode(
Gdx.graphics.getDesktopDisplayMode().width,
Gdx.graphics.getDesktopDisplayMode().height,
true
);
setDisplayMode
方法已不再可用。 - Winter在 Kotlin 中,当用户按下 F 键时将游戏设置为全屏,按下 G 键时将其设置为窗口模式:
override fun render() {
...
if (Gdx.input.isKeyPressed(Input.Keys.F))
Gdx.graphics.setFullscreenMode(Gdx.graphics.displayMode)
if (Gdx.input.isKeyPressed(Input.Keys.G))
Gdx.graphics.setWindowedMode(1280, 720)
...
}