ChoiceLevel.java
上传用户:public
上传日期:2010-01-27
资源大小:484k
文件大小:1k
- package GameDisplay;
- import javax.microedition.lcdui.*;
- public class ChoiceLevel
- extends Form
- implements
- CommandListener, ItemStateListener {
- ChoiceGroup choice;
- Command startCmd;
- Command returnCmd;
- String choiceStr;
- public ChoiceLevel() {
- super("请 您 选 择");
- try {
- jbInit();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- private void jbInit() throws Exception {
- startCmd = new Command("开始", Command.OK, 0);
- returnCmd=new Command("返回",Command.EXIT,0);
- append(" ");
- append(" ");
- append(" ");
- append(" ");
- choice = new ChoiceGroup("游 戏 级 别", Choice.EXCLUSIVE);
- choice.append("简单", null);
- choice.append("普通", null);
- choice.append("较难", null);
- choice.append("困难", null);
- choice.setSelectedIndex(1, true);
- append(choice);
- addCommand(startCmd);
- addCommand(returnCmd);
- setCommandListener(this);
- setItemStateListener(this);
- }
- public void commandAction(Command c, Displayable d) {
- if
- (c.getCommandType() == Command.OK) {
- Control.showGame();
- }
- if(c.getCommandType()==Command.EXIT)
- Control.showMenu();
- }
- public void itemStateChanged(Item item) {
- for (int i = 0; i < choice.size(); i++) {
- if (choice.isSelected(i)) {
- Control.game.vyback = choice.getSelectedIndex() + 2; ///选择相应等级,游戏相应对速度加快
- }
- }
- }
- }