I try to deploy my libgdx game in HTML. In desktop and Android it works well. When I do ./gradlew html:dist
, it compile fine and I have a dist folder which is created in html folder. I succeeded to launch the game on a browser:
However, when I click on any button which will change the screen, the game crash:
The error is :
GwtApplication: exception: (TypeError) : a.g[a.b] is undefined (TypeError) : a.g[a.b] is undefined
and in the console, I have:
Error: java.lang.RuntimeException: com.google.gwt.core.client.JavaScriptException: (TypeError) : a.g[a.b] is undefined
Two questions (1, 2) have the same problem but none of these solved mine.
----- Here is how I change screen ----
When user click on Stats for exemple, my code do that:
button_stats.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y){
stage.addAction(Actions.sequence(Actions.fadeOut(0.2f), Actions.run(new Runnable(){
@Override
public void run() {
ScreenManager.getInstance().showScreen(ScreenEnum.STATS);
}
})));
}
});
Here is my screen manager:
public class ScreenManager {
// Singleton: unique instance
private static ScreenManager instance;
// Reference to game
private SpeedRun2Game game;
// Singleton: private constructor
private ScreenManager() {
super();
}
// Singleton: retrieve instance
public static ScreenManager getInstance() {
if (instance == null) {
instance = new ScreenManager();
}
return instance;
}
// Initialization with the game class
public void initialize(SpeedRun2Game game) {
this.game = game;
}
// Show in the game the screen which enum type is received
public void showScreen(com.gangscred.speedrun2.screens.ScreenEnum screenEnum, Object... params) {
// Get current screen to dispose it
Screen currentScreen = game.getScreen();
// Show new screen
Screen newScreen = screenEnum.getScreen(game , params);
game.setScreen(newScreen);
// Dispose previous screen
if (currentScreen != null) {
currentScreen.dispose();
}
}
}
and finally my screenEnum:
public enum ScreenEnum {
STATS{
public Screen getScreen(SpeedRun2Game game, Object... params){
return new StatsScreen(game);
}
}
----- EDIT -----
I added style = 'PRETTY' option as suggested to my gwt compiler, and now I have this error:
Error: java.lang.RuntimeException: com.google.gwt.core.client.JavaScriptException: (TypeError) : this$static.uniforms[this$static.currProgram] is undefined