📄 uicontroller.java~20~
字号:
package mysubmarine;
import javax.microedition.lcdui.Display;
/**
* <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 MysubmarineMIDlet gameMIDlet;
private Display display;
private Splash splash;
private MySubmarineCanvas gamedisplay;
private Splash nextRound;
public UIController(MysubmarineMIDlet gameMIDlet) {
this.gameMIDlet = gameMIDlet;
this.display = Display.getDisplay(this.gameMIDlet);
}
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);
Thread st = new Thread(this.splash);
try {
st.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
st.start();
break;
case EventID.EVENT_GAME_RUN:
if (gamedisplay == null) {
gamedisplay = new MySubmarineCanvas(this);
}
display.setCurrent(gamedisplay);
gamedisplay.setActive();
splash = null;
nextRound = null;
break;
case EventID.EVENT_NEXTROUND:
if (nextRound == null) {
StringBuffer str = new StringBuffer("Next Round...");
nextRound = new Splash(this, str);
}
display.setCurrent(nextRound);
Thread nr = new Thread(this.nextRound);
try {
nr.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
nr.start();
break;
case EventID.EVENT_EXIT:
this.gameMIDlet.destroyApp(false);
this.gameMIDlet.notifyDestroyed();
break;
}
}
public void setSplash(Splash sp) {
this.splash = sp;
}
public void setNextRoundSplash(Splash nr) {
this.nextRound = nr;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -