gamemidlet.java

来自「j2me 连连看源代码」· Java 代码 · 共 82 行

JAVA
82
字号

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.Display;
/*
 * Created on 2006-1-9
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author aaron
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GameMIDlet extends MIDlet {
    
	private static MainGame main_game;
	
	public static GameMIDlet instance;
	/**
	 * gameMIDlet constructor
	 */
	public GameMIDlet() {
//		main_game = new MainGame(this);
//		if(main_game != null)
//		{
//			main_game.start();
//			Display.getDisplay( this ).setCurrent( main_game );
//		}
		// TODO Auto-generated constructor stub
		instance = this;
	}

	/* (non-Javadoc)
	 * @see javax.microedition.midlet.MIDlet#startApp()
	 */
	protected void startApp() throws MIDletStateChangeException {
		// TODO Auto-generated method stub
        // get the diaplay and start the thread ,then 
		// display the game here
		if(main_game == null)
		{
			main_game = new MainGame(this);
			main_game.start();
			Display.getDisplay( this ).setCurrent( main_game );
		}
		else
		{
			if(MainGame.game_rank != null)
			    Display.getDisplay( this ).setCurrent( MainGame.game_rank  );
			else 
				Display.getDisplay( this ).setCurrent( main_game );
		}
	    MainGame.thread_flag = false;	
	}

	/* (non-Javadoc)
	 * @see javax.microedition.midlet.MIDlet#pauseApp()
	 */
	protected void pauseApp() {
		// TODO Auto-generated method stub
        if(main_game != null)
        	main_game.thread_flag = true;
	}

	/* (non-Javadoc)
	 * @see javax.microedition.midlet.MIDlet#destroyApp(boolean)
	 */
	protected void destroyApp(boolean arg0) {
		// TODO Auto-generated method stub
        
	}
	
	public void exitGame(){
		destroyApp(false);
		notifyDestroyed();
	}
}

⌨️ 快捷键说明

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