I am using VisualMIDlet to make a RPG game in Java Me (sun_java_me_sdk-3_0-win) and I don't know how to change the Scene when game is running.
In the init() before the "real" game runs I have a "map selector" in the main menu:
public class LienzoDelJuego extends GameCanvas implements Runnable {
public LienzoDelJuego(VisualMIDlet unmenu, int mapa) {
super(true);
this.menuPrincipal = unmenu;
this.nummapa = mapa;
this.pausa = false;
d = menuPrincipal.getDisplay();
try {
this.setFullScreenMode(true);
this.init();
} catch (IOException ex) {
ex.printStackTrace();
}
}
and the init():
private void init() throws IOException {
this.timer = new Timer();
this.gameDesign = new Diseny();
this.lm = new LayerManager();
g = getGraphics();
...
switch (nummapa) {
case 0:
this.tlTown = this.gameDesign.getNULL();
this.tlBlock = this.gameDesign.getCasa2();
this.tlWater = this.gameDesign.getNULL();
this.tlBase = this.gameDesign.getCasa1();
gameDesign.updateLayerManagerForCasaW(lm);
break;
case 1:
this.tlTown = this.gameDesign.getNULL();
this.tlBlock = this.gameDesign.getTown2();
this.tlWater = this.gameDesign.getNULL();
this.tlBase = this.gameDesign.getTown1();
gameDesign.updateLayerManagerForTown(lm);
break;
}
and in the run() {} I have a switch too with "nummapa" (the name of the scene) to act different if the number is 1 or 2. The problem is when I try to change the scene or map in the run() code, I really don't know how to do it, I tried this but does not show the textures and sprites of the other map:
else if (spriteW.getY() > 190 && spriteW.getX() > 250 && spriteW.getX() < 270 && nummapa == 0) {
nummapa = 1;
adjustViewport(0, 0);
}
I tried setting some objects to null, "gc" them and recalling but the game freezes. Which is the property way to do that? Thanks!