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

📄 navigator.java

📁 j2me的打飞机的小程序
💻 JAVA
字号:
package GameTest;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Navigator {
	/**
	 * 进入游戏导航界面
	 */
	final public static int MAIN_SCREEN = 1;

	/**
	 * 游戏界面
	 */
	final public static int GAME_SCREEN = 2;

	/**
	 * 设置界面
	 */
	final public static int SET_SCREEN = 3;

	/**
	 * 游戏帮助界面
	 */
	final public static int GAME_HELP_SCREEN = 4;

	/**
	 * 设置帮助界面
	 */
	final public static int SET_HELP_SCREEN = 5;

	/**
	 * 帮助界面
	 */
	final public static int HELP_SCREEN = 6;

	/**
	 * 开始游戏,提示输入名字界面
	 */
	final public static int LOGIN_SCREEN = 7;

	final public static int GAME_OVER_SCREEN = 8;

	public static MIDlet midlet;

	public static Display display;

	public static int current = -1;

	public static int preview = -1;

	public static void show(Object obj) {
		switch (current) {
		case MAIN_SCREEN:
			display.setCurrent(MainScreen.getInstance());
			break;
		case GAME_SCREEN:
			FirstGame game = FirstGame.getInstance();
			if (game != null) {
				new Thread(game).start();
				display.setCurrent(game);
			}
			break;
		case SET_SCREEN:
			display.setCurrent(SetScreen.getInstance());
			break;
		case GAME_HELP_SCREEN:
			display.setCurrent(new HelpScreen((String) "Help\n"
					+ LoginForm.name));
			break;
		case SET_HELP_SCREEN:
			display.setCurrent(new HelpScreen((String) obj));
			break;
		case HELP_SCREEN:
			display.setCurrent(new HelpScreen(""));
			break;
		case LOGIN_SCREEN:
			display.setCurrent(new LoginForm("请输入你的名字"));
			break;
		case GAME_OVER_SCREEN:
			display.setCurrent(new GameOverForm(""));
			break;
		}
	}

	public static void flow(String cmd) {
		switch (current) {
		case MAIN_SCREEN:
			if (cmd.equals("Start")) {
				current = LOGIN_SCREEN;
				show(null);
			} else if (cmd.equals("Setting")) {
				current = SET_SCREEN;
				show(null);
			} else if (cmd.equals("CopyRight")) {
				display.setCurrent(CopyScreen.getInstance());
			} else if (cmd.equals("HELP")) {
				current = HELP_SCREEN;
				show(null);
			} else if (cmd.equals("Quit")) {
				midlet.notifyDestroyed();
			}
			break;
		case GAME_SCREEN:
			if (cmd.equals("EXIT")) {
				current = MAIN_SCREEN;
				show(null);
			}
			break;
		case SET_SCREEN:
			if (cmd.equals("MORE")) {
				current = SET_HELP_SCREEN;
				show("Setting");
			} else if (cmd.equals("BACK")) {
				current = MAIN_SCREEN;
				show(null);
			}
			break;
		case GAME_HELP_SCREEN:
			if (cmd.equals("BACK")) {
				current = GAME_SCREEN;
				show(null);
			}
			break;
		case SET_HELP_SCREEN:
			if (cmd.equals("BACK")) {
				current = SET_SCREEN;
				show(null);
			}
			break;
		case HELP_SCREEN:
			if (cmd.equals("BACK")) {
				current = MAIN_SCREEN;
				show(null);
			}
			break;
		case LOGIN_SCREEN:
			if (cmd.equals("OK")) {
				current = GAME_SCREEN;
				show(null);
			}
			if (cmd.equals("BACK")) {
				current = MAIN_SCREEN;
				show(null);
			}
			break;
		case GAME_OVER_SCREEN:
			if (cmd.equals("EXIT")) {
				current = MAIN_SCREEN;
				show(null);
			}
			break;
		}
	}

	public static int getCurrent() {
		return current;
	}

	/**
	 * 设置当前表示内容标志
	 * 
	 * @param current
	 *            The current to set.
	 */
	public static void setCurrent(int current) {
		preview = Navigator.current;
		Navigator.current = current;
	}
}

⌨️ 快捷键说明

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