How to make LibGDX Desktop go fullscreen by default

↘锁芯ラ 提交于 2019-12-22 04:37:08

问题


all. Just wondering how to make my desktop app go fullscreen upon start up. I am new to LibGDX and any help is greatly appreciated. Thank you.


回答1:


Just define fullscreen field in your LwjglApplicationConfiguration:

LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();

cfg.title = "yourGame";
cfg.width = 1024;
cfg.height = 768;
cfg.fullscreen = true;

new LwjglApplication(new ...(), cfg);



回答2:


To start your game with fullscreen mode set the following flags in LwjglApplicationConfiguration in your Desktop launcher (the main() function)

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);
}

And if you want to enable full screen at any resolution or the desktop's default from an in-game option use

// 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
);


来源:https://stackoverflow.com/questions/20784482/how-to-make-libgdx-desktop-go-fullscreen-by-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!