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

📄 mainmenu.java

📁 StarShip Battle 2004 game The Developing Mobile Phone Applications With J2ME Technology course provi
💻 JAVA
字号:
import javax.microedition.lcdui.*;
import java.io.IOException;

public class MainMenu implements CommandListener {

	//private String[] menuList = {"Start Game", " Set Options", " End Game"};
 
	private List menu;
	private Display deviceDisplay;
	
	private Command startGame;
	private Command setOptions;
	private Command exitGame;
	private Command help;
	
	private Gauge loadingGameGauge;
	private Alert loadingAlert;
	
	private StarShipBattle ssb;
	private UserOptions userOptions;
 	private Battle battle;
 	public MainMenu(StarShipBattle mid, Display d)
 	{
	 	deviceDisplay = d;
	 	menu = new List("Game Menu", Choice.IMPLICIT);
	 	startGame = new Command("Start Game", Command.OK, 1);
	 	setOptions = new Command("Set Options", Command.OK, 1);
	 	help = new Command("Help", Command.HELP, 1);
	 	exitGame = new Command("Exit Game", Command.EXIT, 1);
	 	
	 	menu.addCommand(startGame);
	 	menu.addCommand(setOptions);
	 	menu.addCommand(help);
	 	menu.addCommand(exitGame);
	 	
	 	loadingGameGauge = new Gauge(null, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
	 	loadingGameGauge.setPreferredSize(-1,-1);
	 	loadingAlert = new Alert("Loading Game", "Loading Starship Battle...", null, AlertType.INFO);
	 	menu.setCommandListener(this);
	 	ssb = mid;
	 	userOptions = new UserOptions(d);
	 	userOptions.registerMenu(menu);
	 	battle=new Battle(d,this);//buttom constructor
	 	
 	}
 
	public void commandAction(Command c, Displayable d)
	{
		if(c == startGame){
			startGame();
		} else if (c==setOptions){
			setOptions();
		} else if (c==help){
			showHelp();
		} else if (c==exitGame){
			exitGame();	
		}
	} 
 
 	public void startGame()
 	{
 		//loadingAlert.setImage(null);
 		//loadingAlert.setIndicator(loadingGameGauge);
 		//deviceDisplay.setCurrent(loadingAlert, menu);
	 	battle.start();//in startGame()
	 	deviceDisplay.setCurrent(battle); 		
 	}
 	
 	public void setOptions()
 	{
 		userOptions.showUserOpt();
 	}
 	
 	public void exitGame()
 	{
 		ssb.shutDown();
 	}
 
    public void showMenu()
    {
 		deviceDisplay.setCurrent(menu);
    }  
    
    public void showHelp()
    {
    	
    }  
}

⌨️ 快捷键说明

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