📄 gaem.java
字号:
/*
GAEM - Graphical Adventure Engine for Mobiles (version 0.1)
Copyright (C) 2005 Victor Borrull
This file is part of GAEM.
GAEM is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
GAEM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program;
if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class GAEM extends MIDlet {
Display pantalla;
CanvasJuego game;
FormTitle title;
FormHelp help;
boolean primeraVez = true;
private boolean engineLoaded = false;
private boolean helpLoaded = false;
public GAEM() {
title = new FormTitle(this);
}
/** This method changes the current Display to another. If the current Display is the game itself (new game or load game [CanvasJuego])
* also stops its respective Thread. The different Screens are: TitleScreen, NewGame, LoadGame, Help.
* 0 1 T 1 F 2
*/
public void changeScreen(int screenNumber, boolean newG) {
System.out.println("Changing screen in MIDlet...");
if (newG) { //new game (or title or help)
if (screenNumber == 0) { //title screen
if (engineLoaded)
game.stop();
pantalla.setCurrent(title);
} else if (screenNumber == 1) { //new game
game = new CanvasJuego(this, true);
engineLoaded = true;
game.start();
pantalla.setCurrent(game);
} else if (screenNumber == 2) { //help screen
if (!helpLoaded) {
help = new FormHelp(this);
helpLoaded = true;
}
pantalla.setCurrent(help);
}
} else { //load game
if (screenNumber == 1) {
if (!engineLoaded) {
game = new CanvasJuego(this, false);
engineLoaded = true;
}
game.start();
pantalla.setCurrent(game);
}
}
}
public void changeScreen(int i) { //called for title and help
this.changeScreen(i, true);
}
protected void startApp() {
if (primeraVez) {
pantalla = Display.getDisplay(this);
this.changeScreen(0);
primeraVez = false;
} else {
}
}
public void salir() {
destroyApp(true);
notifyDestroyed();
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
if (engineLoaded)
game.stop();
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -