如何获得显示器分辨率并在DesktopLauncher config.width / height中设置它?

时间:2018-03-09 22:51:23

标签: java libgdx desktop

帮助,我尝试在PC上进行像Terraria一样的分辨率,当它是全屏但仍然是窗口时。为什么这段代码不起作用?

package com.imaginegames.mmgame.desktop;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.imaginegames.mmgame.GameMain;

public class DesktopLauncher {
    public static void main (String[] arg) {
        LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
        config.foregroundFPS = 60;
        config.title = "Millitary Madness";
        config.width = Gdx.graphics.getWidth();
        config.height = Gdx.graphics.getHeight();
        new LwjglApplication(new GameMain(), config);
    }
}

Screen

它说:

线程中的异常" main"显示java.lang.NullPointerException     在com.imaginegames.mmgame.desktop.DesktopLauncher.main(DesktopLauncher.java:13)

0 个答案:

没有答案