📄 petmidlet.java
字号:
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
//主类
public class PetMIDlet extends MIDlet implements Runnable {
static Display display;
SplashScreen splashScreen;
MenuList menu;
HomeCanvas hc ;
private Thread initThread;
//主类构造
public PetMIDlet() {
display = Display.getDisplay(this);
splashScreen = new SplashScreen();
menu = new MenuList(this);
initThread = new Thread(this);
}
//获得display
public Display getDisplay(){
return display;
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO 自动生成方法存根
}
protected void pauseApp() {
// TODO 自动生成方法存根
}
protected void startApp() throws MIDletStateChangeException {
// 显示闪屏
display.setCurrent(splashScreen);
initThread.start();
}
/*public void run() {
// 其他初始化工作
// ....
doSomething();
splashScreen.setProgress(10);
splashScreen.repaint();
// ....
doSomething();
splashScreen.setProgress(50);
splashScreen.repaint();
// ....
doSomething();
splashScreen.setProgress(80);
splashScreen.repaint();
splashScreen.close();
// 显示菜单
display.setCurrent(menu);
}*/
public void run (){
int value=0;
while(value<230){
value+=70;
doSomething();
splashScreen.setProgress(value);
splashScreen.repaint();
}
splashScreen.close();
display.setCurrent(menu);
}
private void doSomething() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
//一下是屏幕切换
//继续游戏
public void menuListContinue() {
// TODO 自动生成方法存根
}
//新游戏
public void menuListNewGame() {
// TODO 自动生成方法存根
Display.getDisplay(this).setCurrent(new NameScreen(this));
}
//游戏说明
public void menuListInstruction() {
// TODO 自动生成方法存根
Display.getDisplay(this).setCurrent(new GameInstruction(this));
}
//游戏存档
public void menuListGameStore() {
// TODO 自动生成方法存根
Display.getDisplay(this).setCurrent(new StoreScreen (this));
}
//主菜单
public void menuList(){
Display.getDisplay(this).setCurrent( new MenuList(this));
}
//游戏退出
public void menuListQuit() {
try {
destroyApp(false);
notifyDestroyed();
} catch (MIDletStateChangeException e) {
}
}
//由游戏说明返回主菜单
public void instructionBack() {
Display.getDisplay(this).setCurrent(menu);
// TODO 自动生成方法存根
}
//游戏存档返回主菜单
public void storeScreenBack(){
Display.getDisplay(this).setCurrent(menu);
}
//进入新游戏即输入宠物姓名屏幕
public void nameScreenback(){
Display.getDisplay(this).setCurrent(menu);
}
//进入查询信息屏幕
public void intoLookInfo() {
// TODO 自动生成方法存根
Display.getDisplay(this).setCurrent(new LookInfo(this));
}
//进入家屏幕
public void intoHomeCanvas(){
Display.getDisplay(this).setCurrent(new HomeCanvas(this));
}
public void intoHomeCanvas1() {
// TODO 自动生成方法存根
Display.getDisplay(this).setCurrent(new HomeCanvas1(this));
}
//查询信息屏幕返回主菜单
public void LookInfoBackmenu() {
// TODO 自动生成方法存根
Display.getDisplay(this).setCurrent(menu);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -