📄 menulist.java
字号:
import javax.microedition.lcdui.*;
class MenuList extends List implements CommandListener
{
private escapeeMIDlet midlet;
private Command exitCommand;
private boolean gameActive = false;
MenuList(escapeeMIDlet midlet)
{
super("逃亡者", 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 c, Displayable d)
{
if (c == List.SELECT_COMMAND)
{
int index = getSelectedIndex();
if (index != -1) // should never be -1
{
if (!gameActive)
{
index++;
}
switch (index)
{
case 0: // Continue
midlet.menuListContinue();
break;
case 1: // New game
midlet.menuListNewGame();
break;
case 2: // High score
midlet.menuListHighScore();
break;
case 3:
midlet.menuListInstructions();
break;
default:
// can't happen
break;
}
}
}
else if (c == exitCommand)
{
midlet.menuListQuit();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -