mazemain.java

来自「是基于J2ME的一个模拟手机的界面可以实现手机收发短信基于客户端和服务器端的功能」· Java 代码 · 共 78 行

JAVA
78
字号
package phone.mediaSound.game.migong;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import phone.Game;
import phone.mediaSound.game.beeShot.MyCanvas;

public class MazeMain extends List implements CommandListener {

	private Game game;

	private Display display;

	private Command cmdOk, cmdGameBACK, cmdBack;

	public MazeMain(Game game, Display display) {
		super("迷宫小游戏", List.IMPLICIT);
		this.display = display;
		this.game = game;

		this.append("开始游戏", null);
		this.append("游戏说明", null);

		cmdOk = new Command("ok", Command.OK, 1);
		cmdGameBACK = new Command("exitGame", Command.BACK, 1);
		cmdBack = new Command("返回", Command.BACK, 1);

		this.addCommand(cmdBack);
		this.addCommand(cmdOk);
		this.setCommandListener(this);
	}

	public void show() {
		display.setCurrent(this);
	}

	public Display getDisplay() {
		return display;
	}

	public void commandAction(Command command, Displayable dis) {
		if (command == cmdGameBACK) {
			display.setCurrent(this);
		} else if (command == cmdOk) {
			int type = this.getSelectedIndex();
			switch (type) {
			case 0:
				MazeGameCanvas mmc = new MazeGameCanvas(this, display);
				Thread th = new Thread(mmc);
				th.start();
				mmc.addCommand(cmdGameBACK);
				mmc.setCommandListener(this);
				display.setCurrent(mmc);
				break;
			case 1:
				Form form = new Form("游戏说明");
				form.append("经典小游戏");

				form.addCommand(cmdBack);
				form.setCommandListener(this);

				display.setCurrent(form);
				break;
			}
		} else if (command == cmdBack) {
			game.getGame();
		}
	}

}

⌨️ 快捷键说明

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