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

📄 menulist.java

📁 我做的手机游戏。有关宠物的
💻 JAVA
字号:



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

public class MenuList  extends List implements CommandListener {
	private Command exitCommand;
	
	private Command choiceCommand;
	
	private PetMIDlet midlet;
	
	private boolean active;
	
	private boolean gameActive;
	
	public MenuList(PetMIDlet midlet){
		super ("主菜单",List.IMPLICIT);
		this.midlet=midlet;
		append("新游戏",null);
		append("游戏说明",null);
		append("读取存档",null);
		append("游戏退出",null);

		exitCommand =new Command("退出",Command.EXIT,1);
		choiceCommand=new Command("选择",Command.SCREEN,1);
		addCommand(exitCommand);
		addCommand(choiceCommand);
		setCommandListener(this);
	}
	
	public  void setGameActive(boolean active){
		if(active&&!gameActive){
		gameActive=true;
		insert(0,"继续游戏",null);
		}else
		if(!active&&gameActive){
		gameActive=false;
		delete (0);
	    }
	}
	
	public void  processMenu(){
		int index=0;
		try{
			List myList=(List)midlet.display.getCurrent();
			index=myList.getSelectedIndex();
			if(!gameActive){
				index++;
			}
			switch(index){
			case 0:
			     midlet.menuListContinue();
			     break;
			  case 1:
			    midlet.menuListNewGame();
			     break;
			  case 2:
				 midlet.menuListInstruction();
				 break;
			  case 3:
			    midlet.menuListGameStore();
			     break;
			  case 4:
				  midlet.menuListQuit();
				  break;
			  
	         }
		}catch(Exception e){}
	}
	
	
   

	public void commandAction(Command c, Displayable d) {
		// TODO 自动生成方法存根
		if(c==exitCommand){
			midlet.menuListQuit();
		}
		if(c==choiceCommand){
		    processMenu();	
		}else{
			processMenu();
			}
		
	}
}

⌨️ 快捷键说明

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