gamemidlet.java

来自「J2ME开发精解原码 第4章内容 大家多多交流 共同提高」· Java 代码 · 共 33 行

JAVA
33
字号
package com.j2medev.chapter5.example;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class GameMIDlet extends MIDlet {
    static GameMIDlet instance;
    
    static Display display;
    
    private GameScreen gameScreen;
    
    public GameMIDlet() {
        instance = this;
        gameScreen = new GameScreen(false); //产生实例
        display = Display.getDisplay(this);
    }
    
    protected void startApp() throws MIDletStateChangeException {
        gameScreen.start();// 启动线程
        display.setCurrent(gameScreen);
    }
    
    protected void pauseApp() {
        gameScreen.stop();// 停止线程
    }
    
    public void destroyApp(boolean flag) throws MIDletStateChangeException {
        gameScreen.stop();// 停止线程
    }
}

⌨️ 快捷键说明

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