問題描述
我正在嘗試使用 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.
這篇關于libGDX HTML5 部署異常的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!