2015-11-09 28 views
2

我正在使用LibGDX創建應用程序並專門部署到GWT HTML5環境。下面的代碼設置我的1280×720分辨率環境如預期:LibGDX自動擴展GWT窗口以監視分辨率

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

,我想我的應用程序是動態調整在加載時間基本上是「全屏幕」(填滿整個瀏覽器空間),不是固定的1280x720。如何在不明確客戶監視器大小的情況下實現這種行爲? (Gdx.graphics.getWidth()和Gdx.graphics.getHeight()返回NPE,因爲我相信getConfig()初始化他們)

回答

3

您將有平臺特定的代碼來做到這一點。 GWT的情況下,這似乎是Window

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

正是我在找的東西 - 謝謝你的回答。 – mcw