uicontroller.java~20~

来自「j2me源代码」· JAVA~20~ 代码 · 共 81 行

JAVA~20~
81
字号
package russiangame;

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

/**
 * <p>Title: 俄罗斯方块</p>
 *
 * <p>Description: 俄罗斯方块游戏</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: Star Group</p>
 *
 * @author not attributable
 * @version 1.0
 */
public class UIController {
    //定义各类事件的ID
    public static class EventID{
        private EventID(){

        }
        public static final byte EVENT_START_SPLASH = 01;
        public static final byte EVENT_GAME_RUN = 02;
        public static final byte EVENT_GAME_PAUSE = 03;
        public static final byte EVENT_EXIT = 04;

        public static final byte EVENT_NEXTROUND = 101;
    }

    private RussianGameMIDlet gameMIDlet;
    private Display display;

    private Splash splash;
    private RussianGameDisplayable gamedisplay;
    private Splash nextRound;

    public UIController(RussianGameMIDlet gameMIDlet) {
        this.gameMIDlet = gameMIDlet;
        this.display = Display.getDisplay(this.gameMIDlet);
        this.handleEvent(EventID.EVENT_START_SPLASH);
    }

    public void handleEvent(byte eventID){
        switch(eventID){
        case EventID.EVENT_START_SPLASH:
            if(splash == null){
                StringBuffer str = new StringBuffer("Starting...");
                splash = new Splash(this,str);
            }
            display.setCurrent(splash);
            break;
        case EventID.EVENT_GAME_RUN:
            if(gamedisplay == null){
                gamedisplay = new RussianGameDisplayable(this);
            }
            display.setCurrent(splash);
            break;
        case EventID.EVENT_NEXTROUND:
            if(nextRound == null){
               StringBuffer str = new StringBuffer("Next Round...");
               nextRound = new Splash(this,str);
           }
           display.setCurrent(nextRound);
            break;
        case EventID.EVENT_EXIT:
            this.gameMIDlet.destroyApp(false);
            break;
        }
    }

    public void setSplash(Splash sp){
        this.splash = sp;
    }

    public void setNextRoundSplash(Splash nr){
        this.nextRound = nr;
    }
}

⌨️ 快捷键说明

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