⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 popogame.java

📁 山洞历险游戏
💻 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);  }}

⌨️ 快捷键说明

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