The forum post new topic button doesn't seem to work for me at the moment, so I'm trying by email. Hope it works.
I'm using 1.9-SNAPSHOT.
I'm displaying some icons for whether sound is enabled and whether a connection to the server has been successfully made.
My code looks like this, and works fine in Java:
Image soundImage;
if(game.getSoundManager().isMuted())
soundImage = assets.getImage(StatusAssets.STATUS_SOUND_DISABLED);
else
soundImage = assets.getImage(StatusAssets.STATUS_SOUND_ENABLED);
Image serverStatusImage;
if(game.getCommunicationStatus())
serverStatusImage = assets.getImage(StatusAssets.STATUS_COMMUNICATION_OK);
else
serverStatusImage = assets.getImage(StatusAssets.STATUS_COMMUNICATION_PROBLEM);
In the HTML5 code, it has however turned into this:
this.game.sounds.isMuted?(soundImage = $getImage_4(this.assets, 2)):(soundImage = $getImage_4(this.assets, 1));
this.game.isServerCommunicationsOk?(serverStatusImage = $getImage_4(this.assets, 3)):(serverStatusImage = $getImage_4(this.assets, 4));
As
you can see, the call to game.getSoundManager() has turned into
game.sounds, while game.getCommunicationStatus() has turned into
game.isServercommunicationsOk. When loading, the game crashes and the
web console is flooded with messages that "this.game.sounds is
undefined". That particular object seems to have been renamed to
this$static.sounds, so it's not very surprising that it can't find it
anymore:
this$static.sounds = new SoundManager_0(this$static);
I suppose the "correct" conversion would be something like this, where the $static has been added:
this.game$static.sounds.isMuted?(soundImage = $getImage_4(this.assets, 2)):(soundImage = $getImage_4(this.assets, 1));
this.game$static
.isServerCommunicationsOk?(serverStatusImage = $getImage_4(this.assets, 3)):(serverStatusImage = $getImage_4(this.assets, 4));
Any
idea if there is some configuration that prevents it from trying to
optimize accessors into variable access? Or any way to rewrite my code so that it will
still pick the right variable name when rewriting everything?