libGDX localhost:8080 上符合 superDev 的游戏只显示一个按钮

libGDX game complied to superDev on localhost:8080 only shows one button

我无法使用 gradlew html:superDev

在浏览器中获取我的 libGDX 游戏

在我的 IDE (Inteliji) 中的终端上执行命令 gradlew html:superDev 后,我得到响应:代码服务器已准备就绪 http://127.0.0.1:9876/

我导航到那个网站,复制书签,当我尝试使用网站 http://localhost:8080/index.html 玩我的游戏时,只出现一个灰色的重新加载按钮!

当我点击按钮时,我得到一个 编译 选项,它什么都不做。

编译后,在终端,向上滚动,我看到了很多 X can't be instantiated. Constructors not generated

not emitting code for accessing field mask in class 'com.badlogic.x.x.x' as its of type long which 
can't be used with JSNI
 

(以及更多) 我真的不确定这些是否与问题有关。

我在其他网站上搜索过这个问题,但答案要么不是我的问题,要么太vague/didin不举例子。

问题是什么?另外,有没有办法查看日志,看看哪里出了问题?

编辑:

我查看了游戏的控制台,看到以下错误:

Uncaught TypeError: $wnd.SoundManager is not a constructor
    at kB_g$ (SoundManager.java:75)
    at VZl_g$.ol_g$ [as onModuleLoad_0_g$] (GwtApplication.java:144)
    at Array.YNi_g$ (max_00046worldofsquares_00046GdxDefinitionSuperdev__EntryMethodHolder.java:3)
    at initializeModules_0_g$ (ModuleUtils.java:44)
    at iZg_g$ (Impl.java:309)
    at lZg_g$ (Impl.java:368)
    at Impl.java:78
    at qNi_g$ (ModuleUtils.java:55)
    at TileType.java:3

当我点击“SoundManager.java.75”时,它给了我这个构造函数:

public static native void init (String moduleBaseURL, int flashVersion, boolean preferFlash, SoundManagerCallback callback) /*-{
        $wnd.soundManager = new $wnd.SoundManager(); **< ERROR IS HERE**
        $wnd.soundManager.audioFormats.mp3.required = false;
        $wnd.soundManager.setup({
            url: moduleBaseURL,
            flashVersion: flashVersion,
            preferFlash: preferFlash,
            onready: function() { 
                callback.@com.badlogic.gdx.backends.gwt.soundmanager2.SoundManager.SoundManagerCallback::onready()();
            },
            ontimeout: function(status) {
                callback.@com.badlogic.gdx.backends.gwt.soundmanager2.SoundManager.SoundManagerCallback::ontimeout(Ljava/lang/String;Ljava/lang/String;)(status.success, (typeof status.error === 'undefined') ? '' : status.error.type);
            }
                    
        });
        $wnd.soundManager.beginDelayedInit();
    }-*/;

}

这很奇怪,因为我的游戏甚至没有声音。

问题与最新的安装应用程序为 libGDX 1.9.12 的快照版本生成模板文件有关,但您使用的是较旧的 libGDX。

两种解决方法:

  • 使用libGDX 1.9.12-SNAPSHOT

额外的快速修复:在 HTML 配置中停用音频。

在 1.9.11 版本中,您可以通过禁用音频来临时绕过。

在 html 模块中的文件 HtmlLauncher.java 编辑为:

public class HtmlLauncher extends GwtApplication {
    //some stuff
    @Override
    public GwtApplicationConfiguration getConfig () {
        GwtApplicationConfiguration configuration;
        configuration = new GwtApplicationConfiguration(480, 320);
        configuration.disableAudio = true;
        return configuration;
    }
    //some stuff
}