simplegamemidlet.java

来自「J2ME手机游戏开发技术详解随书光盘」· Java 代码 · 共 41 行

JAVA
41
字号
// Any use of this code and/or information below is subject to the
// license terms: http://wireless.java.sun.com/berkeley_license.html

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class SimpleGameMIDlet
    extends MIDlet
    implements CommandListener {
  private Display mDisplay;
  
  private SimpleGameCanvas mCanvas;
  private Command mExitCommand;
  
  public void startApp() {
    if (mCanvas == null) {
      mCanvas = new SimpleGameCanvas();
      mCanvas.start();
      mExitCommand = new Command("Exit", Command.EXIT, 0);
      mCanvas.addCommand(mExitCommand);
      mCanvas.setCommandListener(this);
    }
    
    mDisplay = Display.getDisplay(this);
    mDisplay.setCurrent(mCanvas);//Display.getDisplay(this).setCurrent(mCanvas);
  }
  
  public void pauseApp() {}
  
  public void destroyApp(boolean unconditional) {
    mCanvas.stop();
  }
  
  public void commandAction(Command c, Displayable s) {
    if (c.getCommandType() == Command.EXIT) {
      destroyApp(true);
      notifyDestroyed();
    }
  }
}

⌨️ 快捷键说明

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