📄 myfly.java
字号:
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
/** /?? MyFly ?/ */
public class MyFly extends MIDlet implements CommandListener {
/** /?? 定义GameMain对象 ?/ */
private GameMain gm;
/** /?? 定义Command对象 ?/ */
private Command exitcmd;
/** /?? 定义Command对象 ?/ */
private Command restartcmd;
/** /?? 定义Command对象 ?/ */
private Command startcmd;
/** /?? startApp() ?/ */
protected final void startApp() {
if (gm == null) {
gm = new GameMain(Display.getDisplay(this));
/** /??GameCanvas继承Canvas类,Canvas类继承Displayable类,使用父类的父类方法 ?/ */
startcmd = new Command("start", Command.OK, 1);
exitcmd = new Command("exit", Command.EXIT, 1);
gm.addCommand(startcmd);
gm.addCommand(exitcmd);
gm.setCommandListener(this);
}
gm.gameStart();
}
/** /?? pauseApp() ?/ */
protected void pauseApp() {
}
/** /?? pauseApp()
?@param e ?/ */
protected void destroyApp(final boolean e) {
}
/** /?? commandAction
?@param c
?@param d ?/ */
public final void commandAction(final Command c, final Displayable d) {
String cmd = c.getLabel();
if (cmd.equals("start")) {
gm.removeCommand(startcmd);
restartcmd = new Command("restart", Command.OK, 1);
gm.addCommand(restartcmd);
gm.start();
}
if (cmd.equals("restart")) {
gm.clearJob();
clearJob();
if (gm == null) {
gm = new GameMain(Display.getDisplay(this));
/** /??GameCanvas继承Canvas类,Canvas类继承Displayable类,使用父类的父类方法?/ */
startcmd = new Command("restart", Command.OK, 1);
exitcmd = new Command("exit", Command.EXIT, 1);
gm.addCommand(startcmd);
gm.addCommand(exitcmd);
gm.setCommandListener(this);
gm.start();
}
}
if (cmd.equals("exit")) {
gm.clearJob();
clearJob();
this.destroyApp(false);
this.notifyDestroyed();
}
}
/** /?? pauseApp() ?/ */
private void clearJob() {
gm = null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -