www.pudn.com > ch8-spaceshooter.rar > SpaceShooter.java


/* 
 * SpaceShooter.java 
 * 
 * Copyright 2001 SkyArts. All Rights Reserved. 
 */ 
import javax.microedition.midlet.*; 
import javax.microedition.lcdui.*; 
 
/** 
 * Space Shooter扩展自MIDlet类 
 * 
 * @author  Hideki Yonekawa 
 * @version 1.0 
 */ 
public class SpaceShooter extends MIDlet { 
	/** 储存了GameCanvas的变量 */ 
	private GameCanvas			gameCanvas; 
 
	/** 构造函数 */ 
	public SpaceShooter() { 
		gameCanvas = new GameCanvas(this); 
		Display.getDisplay(this).setCurrent(gameCanvas); 
	} 
 
	/** MIDlet开始时所调用的方法 */ 
	protected void startApp() throws MIDletStateChangeException { 
		gameCanvas.doStartApp(); 
	} 
 
	/** MIDlet暂停时所调用的方法 */ 
	protected void pauseApp() { 
		gameCanvas.doPauseApp(); 
	} 
 
	/** MIDlet结束时所调用的方法 */ 
	protected void destroyApp(boolean unconditional) 
		throws MIDletStateChangeException {} 
 
	/** 结束MIDlet时所调用的方法 */ 
	void doExit() { 
		try { 
			destroyApp(false); 
			notifyDestroyed(); 
		}catch(MIDletStateChangeException e) {} 
	} 
}