libGDX HTML5 部署异常

2022-01-12 00:00:00 html gwt libgdx

我正在尝试使用 GWT 编译 libGDX 项目(libgdx-project-html 右键单击​​ -> Google -> GWT 编译).

I am trying to compile the libGDX project using GWT (libgdx-project-html right click -> Google -> GWT Compile).

编译时没有错误,除了

com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Targetjava.lang.StringIndexOutOfBoundsException

com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Target java.lang.StringIndexOutOfBoundsException

但由于我没有使用此工具,所以应该没有问题.

but since I'm not using this util should not be a problem.

编译说成功后,我运行本地托管站点.

After the compilation says that it was successful, I ran the local hosted site.

LibGDX 标志和加载栏出现(直到这里还不错),当它们完成后,我得到一个黑色的游戏屏幕和一个无限的框

LibGDX logo and loading bar come up (fine until here), and when they are done, I get a black game screen and a box below it with unlimited

GwtApplication:异常:(TypeError):无法调用方法null (TypeError) 的nullMethod":无法调用方法nullMethod"的空

GwtApplication: exception: (TypeError) : Cannot call method 'nullMethod' of null (TypeError) : Cannot call method 'nullMethod' of null

消息行.

在控制台中不断重复以下消息:

In the console the following message is repeated continuously:

未捕获的 java.lang.RuntimeException:com.google.gwt.core.client.JavaScriptException: (TypeError) : 不能调用null的方法'nullMethod'(匿名函数)597957B2399D3903739C615799AE1A15.cache.html:11899

Uncaught java.lang.RuntimeException: com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot call method 'nullMethod' of null (anonymous function) 597957B2399D3903739C615799AE1A15.cache.html:11899

这个项目基本上就是libGDX的标志,应该出现并填满游戏屏幕(默认),并且没有修改任何代码.

The project basically is nothing but the logo of libGDX that should come up and fill the game screen (the default one) and no code has been modified.

一些补充说明:

桌面和 Android 可以完美地编译和工作.

Desktop and Android compile and work flawlessly.

在出现该错误消息之前,控制台显示 SoundManager 2 已加载(确定).

Console says SoundManager 2 loaded (OK) before that error message comes up.

GWT 编译时设置了严格标志,并且所有内容都编译没有错误.

Strict flag is set when GWT compiling and everything are compiled with no errors.

推荐答案

适用于遇到相同问题或任何其他类似/奇怪异常的任何人.

For anyone having the same problem or any other similar/weird exceptions.

确保通过添加设置严格标志

Make sure that strict flag is set by adding

-严格

在编译参数中,最重要的是,您正在使用

in the compiling arguments and most importantly, you are using

GL20

因为 WebGL 基于 GL20,不支持 GL10.

as WebGL is based on GL20 and doesn't support GL10.

相关文章