英文:
libGDX game complied to superDev on localhost:8080 only shows one button
问题
以下是您要翻译的内容:
我无法通过 gradlew html:superDev
在浏览器中运行我的 libGDX 游戏。
在我的集成开发环境(Inteliji)中的终端内执行命令 gradlew html:superDev
后,我得到以下回应:代码服务器已准备就绪,位于 http://127.0.0.1:9876/
我导航到该站点,复制书签,然后当我尝试使用网址 http://localhost:8080/index.html
玩游戏时,只有一个灰色的重新加载按钮!
当我点击该按钮时,出现一个 编译 选项,但没有任何反应。
编译后,在终端中向上滚动,我看到许多类似于以下的信息:
X 无法实例化。未生成构造函数
以及
无法发出代码以访问类 'com.badlogic.x.x.x' 中的字段 mask,因为它的类型为 long,无法与 JSNI 一起使用
(以及更多)
我真的不确定这些是否与问题有关。
我在其他网站上搜索了这个问题,但答案要么不完全符合我的问题,要么太模糊/没有给出示例。
问题是什么?另外,有没有办法查看日志以查明出了什么问题?
编辑:
我查看了游戏的控制台,看到以下错误:
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(); **< 错误发生在这里**
$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();
}-*/;
}
这很奇怪,因为我的游戏甚至没有声音。
英文:
I am unable to get my libGDX game in the browser using gradlew html:superDev
After executing the command gradlew html:superDev
on a terminal inside my IDE (Inteliji), I get the response: The code server is ready at http://127.0.0.1:9876/
I navigate to that site, copy the bookmarks, and when I try to play my game using the website http://localhost:8080/index.html
, only a grey reload button appears!
When I click the button, I get a compile option, which does nothing.
After compiling, In the terminal, scrolling up, I see a lot of
X can't be instantiated. Constructors not generated
and
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
(and more)
I am really unsure if these are even related to the problem.
I have searched up this question on other sites, but the answers were either not exactly what my problem was, or too vague/didin't give an example.
What is the problem? Additionally, is there a way to view the log to see what went wrong?
EDIT:
I have looked in the console of the game, and I see the following error:
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
When I click on "SoundManager.java.75" it gives me this construstor:
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();
}-*/;
}
Which is weird, because my game doesn't even have sounds.
答案1
得分: 4
问题的关键在于最新的安装设置应用程序为libGDX 1.9.12生成了快照版本的模板文件,但你使用的是较旧的libGDX。
解决方法有两种:
- 使用libGDX 1.9.12-SNAPSHOT
或者
- 通过从Github下载标签1.9.11的内容,将你的html/war目录合并到1.9.11风格。
额外的快速修复方法:在HTML配置中禁用音频。
英文:
The problem is related that the latest setup application generates the template files for the snapshot version for libGDX 1.9.12, but you use an older libGDX.
Two ways to resolve this:
- Use libGDX 1.9.12-SNAPSHOT
or
- Merge your html/war directory to the 1.9.11 style by downloading its content at tag 1.9.11 from Github.
Bonus quickfix: Deactivate audio in the HTML config.
答案2
得分: 0
在版本1.9.11中,您可以通过禁用音频进行临时绕过。
在html模块的HtmlLauncher.java文件中进行编辑:
public class HtmlLauncher extends GwtApplication {
//一些内容
@Override
public GwtApplicationConfiguration getConfig () {
GwtApplicationConfiguration configuration;
configuration = new GwtApplicationConfiguration(480, 320);
configuration.disableAudio = true;
return configuration;
}
//一些内容
}
英文:
In version 1.9.11 you can temp bypass by disable audio.
At file HtmlLauncher.java in html module edit to:
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
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论