問題描述
我正在嘗試使用 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
但由于我沒有使用此工具,所以應(yīng)該沒有問題.
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 標(biāo)志和加載欄出現(xiàn)(直到這里還不錯),當(dāng)它們完成后,我得到一個黑色的游戲屏幕和一個無限的框
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):無法調(diào)用方法null (TypeError) 的nullMethod":無法調(diào)用方法nullMethod"的空
GwtApplication: exception: (TypeError) : Cannot call method 'nullMethod' of null (TypeError) : Cannot call method 'nullMethod' of null
消息行.
在控制臺中不斷重復(fù)以下消息:
In the console the following message is repeated continuously:
未捕獲的 java.lang.RuntimeException:com.google.gwt.core.client.JavaScriptException: (TypeError) : 不能調(diào)用null的方法'nullMethod'(匿名函數(shù))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的標(biāo)志,應(yīng)該出現(xiàn)并填滿游戲屏幕(默認),并且沒有修改任何代碼.
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.
在出現(xiàn)該錯誤消息之前,控制臺顯示 SoundManager 2 已加載(確定).
Console says SoundManager 2 loaded (OK) before that error message comes up.
GWT 編譯時設(shè)置了嚴格標(biāo)志,并且所有內(nèi)容都編譯沒有錯誤.
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.
確保通過添加設(shè)置嚴格標(biāo)志
Make sure that strict flag is set by adding
-嚴格
在編譯參數(shù)中,最重要的是,您正在使用
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.
這篇關(guān)于libGDX HTML5 部署異常的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!