menuscreen.java

来自「一个经典的手机游戏原代码」· Java 代码 · 共 54 行

JAVA
54
字号
import javax.microedition.lcdui.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class menuScreen extends Canvas implements CommandListener{  gameMIDlet gameMid;  gameScreen game;  Command playCommand = new Command("开始", Command.ITEM, 1);  Command exitCommand = new Command("退出", Command.EXIT, 1);  private Display display;  private Image img;  public menuScreen(Display display, Image img, gameMIDlet gameMid) {    this.display = display;    this.img = img;    this.gameMid = gameMid;    addCommand(playCommand);    addCommand(exitCommand);    setCommandListener(this);  }  protected void paint(Graphics g) {    /**@todo Implement this javax.microedition.lcdui.Canvas abstract method*/    g.setColor(0x00FFFFFF);    g.fillRect(0, 0, getWidth(), getHeight());    g.setColor(0x00000000);    g.drawImage(img, getWidth()/2, getHeight()/2-5, 3);  }  public void commandAction(Command c, Displayable d) {    if (c == playCommand) {      game = null;      game = new gameScreen(display, this);      game.start();      display.setCurrent(game);    } else if (c == exitCommand) {      game = null;      gameMid.destroyApp(true);      gameMid.notifyDestroyed();    }  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?