?? popogame.java
字號:
package popo;import javax.microedition.lcdui.*;import javax.microedition.midlet.*;import java.io.*;import javax.microedition.rms.*;import java.util.Vector;import java.util.Random;import java.io.IOException;public class popoGame extends MIDlet implements CommandListener{ Display display; StartCanvas Start; private Alert alert; private Form mainForm; private final String GameName = "PopoName";//游戲名稱 private Command exitCommand; public popoGame() { display = Display.getDisplay(this); Start = new StartCanvas(this); mainForm = new Form(GameName); mainForm.append(GameName); exitCommand = new Command("Exit", Command.EXIT, 1); alert = new Alert("Warning"); } public void commandAction(Command c, Displayable s) { if(c == exitCommand) { destroyApp(false); notifyDestroyed(); } } public void startApp() { //讀入圖片 display.setCurrent(mainForm); Vector images = new Vector(5); Start.reset(); try { try { String name; name = "/jiemian1.png"; //start主界面 images.addElement(createImage(name)); name = "/jiemian2.png"; //start選擇按鈕 images.addElement(createImage(name)); } catch (IOException io_ex) { alert.setString("Images could not be loaded."); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } if (images.size() > 0) { Start.setImages(images); display.setCurrent(Start); } else { alert.setString("Images could not be loaded."); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } } catch (OutOfMemoryError err) { int size = images.size(); if (size > 0) { images.setSize(size-1); } alert.setString("Not enough memory for all images."); // If no images are loaded, Alert and return to the list // Othersize, Alert and display the ones that were loaded. if (images.size() <= 0) { display.setCurrent(alert); display.setCurrent(null); } else { Start.setImages(images); display.setCurrent(alert); display.setCurrent(Start); } } } public void pauseApp() { } public void destroyApp(boolean unconditional) { } private Image createImage(String name) throws IOException { return Image.createImage(name); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -