📄 menulist.java
字号:
/*
* MenuList.java
*
* Created on 2006年11月24日, 下午6:30
*
* 游戏菜单选项类 -- 显示菜单选项内容 新游戏、高分纪录、游戏说明、暂停后的继续游戏
*/
import javax.microedition.lcdui.*;
/**
*
* @author TOM
*/
public class MenuList extends List implements CommandListener{
private ManMidlet midlet;
private Command exitCommand;
private boolean gameActive = false;
/** Creates a new instance of MenuList */
public MenuList(ManMidlet midlet) {
super("坚持20秒",List.IMPLICIT);
this.midlet = midlet;
append("新游戏",null);
append("高分纪录",null);
append("游戏说明", null);
exitCommand = new Command("退出",Command.EXIT,1);
addCommand(exitCommand);
setCommandListener(this);
}
void setGameActive(boolean active){
if(active && !gameActive){
gameActive = true;
insert(0,"继续游戏",null); //添加“继续游戏”选项
}else if(!active && gameActive){
gameActive = false;
delete(0);
}
}
public void commandAction(Command cmd,Displayable display){
if(cmd == List.SELECT_COMMAND){
int index = getSelectedIndex();
if(index != -1){
if(!gameActive){
index++; //如果有“继续游戏”选项,后面的选项索引依次加1
}
switch(index){
case 0: //Continue
midlet.menuListContinue(); //继续游戏
break;
case 1: //New Game
midlet.menuListNewGame(); //新游戏
break;
case 2: //High Score
midlet.menuListHighScore(); //高分纪录
break;
case 3: //Intruction
midlet.menuListInstructions(); //游戏说明
break;
default:
break;
}
}
}else if(cmd.getCommandType() == Command.EXIT){
midlet.menuListQuit();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -