📄 tilelayertest.java
字号:
package tilelayer;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class TileLayerTest extends MIDlet implements CommandListener {
static TileLayerTest instance;
private Command cmPause; // 暂停按钮
private Command cmContinue; //继续按钮
private Command cmExit; // 退出按钮
private Command cmUpGread; // 升级按钮
private Command cmReduceGread; //降级按钮
private Command cmRestart; //重新开始
private Command cmGoon; //继续往下
private Command cmPassWD;
private Command cmSure;
private Command cmBack;
UserNameForm UserForm = new UserNameForm();
GameCanvasOBJ displayable = new GameCanvasOBJ(false);
public TileLayerTest() {
instance = this;
cmContinue = new Command("Continue", Command.SCREEN, 1);
cmPause = new Command("Pause", Command.SCREEN, 1);
cmUpGread = new Command("Up gread", Command.SCREEN, 2);
cmReduceGread = new Command("Recude gread", Command.SCREEN, 2);
cmExit = new Command("Exit", Command.EXIT, 1);
cmRestart = new Command("Restart", Command.SCREEN, 2);
cmGoon = new Command("Go on", Command.SCREEN, 2);
cmPassWD = new Command("Pass word", Command.SCREEN, 2);
cmSure = new Command("ok", Command.SCREEN, 2);
cmBack = new Command("Back", Command.BACK, 2);
displayable.addCommand(cmPause);
displayable.addCommand(cmUpGread);
displayable.addCommand(cmReduceGread);
displayable.addCommand(cmExit);
displayable.addCommand(cmPassWD);
displayable.setCommandListener(this);
}
public void startApp() {
Display.getDisplay(this).setCurrent(displayable);
displayable.GetMiDletObj(this);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public static void quitApp() {
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
public void commandAction(Command c, Displayable s) {
if (c == cmExit) {
quitApp();
} else if (c == cmPause) {
displayable.removeCommand(cmPause);
displayable.addCommand(cmContinue);
displayable.GamePause();
} else if (c == cmUpGread) {
displayable.UpGread();
} else if (c == cmReduceGread) {
displayable.ReduceGread();
} else if (c == cmContinue) {
displayable.removeCommand(cmContinue);
displayable.addCommand(cmPause);
displayable.GamePause();
} else if (c == cmRestart) {
AddCommandAgain();
displayable.RestartGame();
} else if (c == cmGoon) {
AddCommandAgain();
displayable.GoonGame();
} else if (c == cmPassWD) {
UserForm.AddTextFile();
Display.getDisplay(this).setCurrent(UserForm);
UserForm.addCommand(cmSure);
UserForm.addCommand(cmBack);
UserForm.setCommandListener(this);
} else if (c == cmBack) {
Display.getDisplay(this).setCurrent(displayable);
} else if (c == cmSure) {//如果输入的字符不正确则进入下面的处理
if (!UserForm.CheckPWD()) {
Alert al = new Alert("Error");
al.setType(AlertType.ALARM);
al.setString("密码错误,请从新输入!");
al.setTimeout(Alert.FOREVER);
Display.getDisplay(this).setCurrent(al);
} else {//如果输入的字符正确则进入下面的处理
Alert al = new Alert("haha");
al.setType(AlertType.ALARM);
al.setTimeout(Alert.FOREVER);
Display.getDisplay(this).setCurrent(al);
}
}
}
public void ChangeCommand() {
//displayable.removeCommand(cmContinue);
displayable.removeCommand(cmPause);
displayable.removeCommand(cmUpGread);
displayable.removeCommand(cmReduceGread);
displayable.addCommand(cmRestart);
displayable.addCommand(cmGoon);
}
public void AddCommandAgain() {
displayable.removeCommand(cmRestart);
displayable.removeCommand(cmGoon);
displayable.addCommand(cmPause);
displayable.addCommand(cmUpGread);
displayable.addCommand(cmReduceGread);
}
public void ShowPWDInputForm() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -