PaoPao.java
上传用户:sh2222
上传日期:2009-12-31
资源大小:84k
文件大小:2k
- package paopao;
- import javax.microedition.midlet.*;
- import javax.microedition.lcdui.*;
- public class PaoPao extends MIDlet {
- private static PaoPao instance;
- private static Logo logo;
- private static Menu menu;
- private static GameWorld gw;
- static boolean isNewGame = true;
- static final int LOGO_ID = 1;
- static final int MENU_ID = 2;
- static final int GAMEWORLD_ID = 3;
- /** Constructor */
- public PaoPao() {
- instance = this;
- }
- private static void loadResource()
- {
- Resource.init(40);
- for(int i = 1; i <= 15;i ++)
- Resource.setImage(i,Resource.DIR + "point" + i * 6 + ".png");
- Resource.setImage(Resource.BG,Resource.DIR + "bg.png");
- Resource.setImage(Resource.BALL,Resource.DIR + "ball.png");
- // Resource.setImage(Resource.BALL_BOMB,Resource.DIR + "ball_bomb.png");
- // Resource.setImage(Resource.POINT,Resource.DIR + "point.png");
- // Resource.setImage(Resource.AID_LINE,Resource.DIR + "aid_line.png");
- //Resource.setImage(Resource.PROPS,Resource.DIR + "props.png");
- //Resource.setImage(Resource.BBALL,Resource.DIR + "bball.png");
- }
- /** Main method */
- public void startApp() {
- if(isNewGame)
- {
- Resource.loadAngleValue();
- loadResource();
- isNewGame = false;
- shiftCanvas(GAMEWORLD_ID,6);
- }
- }
- /** Handle pausing the MIDlet */
- public void pauseApp() {
- }
- /** Handle destroying the MIDlet */
- public void destroyApp(boolean unconditional) {
- gw = null;
- isNewGame = true;
- instance.notifyDestroyed();
- instance = null;
- System.gc();
- }
- /** Quit the MIDlet */
- public static void quitApp() {
- instance.destroyApp(true);
- }
- protected static void shiftCanvas(int canvasId,int hardLevel)
- {
- switch(canvasId)
- {
- case LOGO_ID:
- logo = new Logo();
- Display.getDisplay(instance).setCurrent(logo);
- break;
- case MENU_ID:
- menu = new Menu();
- Display.getDisplay(instance).setCurrent(menu);
- break;
- case GAMEWORLD_ID:
- if(gw == null)
- gw = new GameWorld(hardLevel);
- gw.show();
- Display.getDisplay(instance).setCurrent(gw);
- break;
- default :
- break;
- }
- }
- }