LibGDX Automatically Scaling GWT Window to Monitor Resolution

守給你的承諾、 提交于 2019-12-24 04:02:53

问题


I'm creating an application with LibGDX and deploying exclusively to a GWT HTML5 environment. The below code sets up my environment with a 1280x720 resolution as expected:

public class HtmlLauncher extends GwtApplication {

    @Override
    public GwtApplicationConfiguration getConfig() {
        return new GwtApplicationConfiguration(1280, 720); // <-- here is line of code in question
    }

    @Override
    public ApplicationListener getApplicationListener() {
        return Engine.getInstance();
    }
}

I would like my application to be dynamically sized at load-time as essentially "full screen" (filling up the entire browser space), and not a fixed 1280x720. How can I achieve this behavior without knowing specifically the client's monitor size? (Gdx.graphics.getWidth() and Gdx.graphics.getHeight() return NPE as I believe getConfig() initializes them)


回答1:


You will have to do this with platform specific code. In case of GWT, this seems to be Window.

return new GwtApplicationConfiguration(Window.getClientWidth(), Window.getClientHeight());


来源:https://stackoverflow.com/questions/33618342/libgdx-automatically-scaling-gwt-window-to-monitor-resolution

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