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

📄 menulist.java

📁 类似于推箱子的手机游戏源码
💻 JAVA
字号:
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
/*
 * MenuList.java
 *
 * Created on 2007年10月20日, 下午10:26
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author liang
 */
public class MenuList extends List implements CommandListener{
    private Hunt_Midlet midlet;
    private Command exitCommand;
    private static boolean flag = false;//标记是否已有“继续游戏”选项
    
    /** Creates a new instance of MenuList */
    public MenuList(Hunt_Midlet Hmidlet) {
        super("Super Hunter",List.IMPLICIT);
        this.midlet = Hmidlet;
        
        append("新游戏",null);        
        append("游戏说明", null);
        exitCommand = new Command("退出",Command.EXIT,1);
        addCommand(exitCommand);
        setCommandListener(this);        
    }
    
    public void setGameActive(boolean show){//进行“继续游戏”选项显示与不显示的切换
        if( show && !flag){//设置"继续游戏"选项,并且当前没有继续游戏选项
            flag = true;
            insert(0,"继续游戏",null);  //添加“继续游戏”选项
        }
        else{
           if( !show && flag ){//取消“继续游戏”选项。并且当前有继续游戏选项
               flag = false;
               delete(0);
           }
        }
    
    }

    public void commandAction(Command cmd, Displayable displayable) {
        if( cmd == List.SELECT_COMMAND ){
            int index = getSelectedIndex();
            if(index != -1){
               if(flag == false){
                  index++;//当前没有“继续游戏”选项,所选脚标值加一
               }
               
              switch(index){
                   case 0:
                       midlet.MenuListContinue();
                       break;
                   case 1:
                       if(flag == false){
                            midlet.MenuListNewGame();
                       }
                       else 
                           midlet.CanvasNewGame();
                       break;
                   case 2:
                       midlet.MenuListInstruction();
                       break;
                   default:
                       break;
               }
            }
        
        }
        else{
            if( cmd.getCommandType() == Command.EXIT ){
                midlet.MenuListQuit();
            }
        }
    }
    
}

⌨️ 快捷键说明

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