mainmenu.java

来自「StarShip Battle 2004 game The Developing」· Java 代码 · 共 88 行

JAVA
88
字号
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 + =
减小字号Ctrl + -
显示快捷键?