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

📄 m3gmidlet.java

📁 一个3D游戏的实例
💻 JAVA
字号:
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class M3GMidlet extends MIDlet implements CommandListener
{
    // A variable that holds the unique display
	private Display display = null;
	
	// The canvas
	private M3GCanvas canvas = null;
	
	// The MIDlet itself
	private static MIDlet self = null;

	/** Called when the application starts, and when it is resumed.
	 * We ignore the resume here and allocate data for our canvas
	 * in the startApp method. This is generally very bad practice.
	 */
	protected void startApp() throws MIDletStateChangeException
	{
	    // Allocate
		display = Display.getDisplay(this);
		canvas = new M3GCanvas(30);
		
		// Add a quit command to the canvas
		// This command won't be seen, as we
		// are running in fullScreen mode
		// but it's always nice to have a quit command
		canvas.addCommand(new Command("Quit", Command.EXIT, 1));
		
		// Set the listener to be the MIDlet
		canvas.setCommandListener(this);
		
		// Start canvas
		canvas.start();
		display.setCurrent(canvas);
		
		// Set the self
		self = this;
	}

	/** Called when the game should pause, such as during a call */
	protected void pauseApp()
	{
		
	}

	/** Called when the application should shut down */
	protected void destroyApp(boolean unconditional) throws MIDletStateChangeException
	{
	    // Method that shuts down the entire MIDlet
		notifyDestroyed();
	}

	/** Listens to commands and processes */
    public void commandAction(Command c, Displayable d) {
        // If we get an EXIT command we destroy the application
        if(c.getCommandType() == Command.EXIT)
            notifyDestroyed();
    }
    
    /** Static method that quits our application
     * by using the static field 'self' */
    public static void die()
    {
        self.notifyDestroyed();
    }
}

⌨️ 快捷键说明

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