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

📄 menulist.java

📁 此为一款基于J2ME的手机游戏
💻 JAVA
字号:
/**********************************************************
  
 File name:MenuList.java
 
 Author:夏文涛
 
 Version:Beta1.0
 
 Data:2007/10/16
  
 Description:
 
    手机菜单的显示和处理.
    
 Function List:
 
    1.setGameActive(boolean) 
      更新游戏运行状态.如果暂停游戏,则加入"继续游戏"项.

 *********************************************************/

package com.Izual.MetalMax;


import javax.microedition.lcdui.*;


public class MenuList extends List implements CommandListener{
	
	private MetalMax midlet;
	private Command exitCommand;
	
	/*游戏是否暂停*/
	private boolean gameActive = false;

	public MenuList(MetalMax midlet) {
		// TODO 自动生成构造函数存根
		
		super("MetalMax",List.IMPLICIT);
		this.midlet = midlet;
		append("新游戏",null);
		append("读取进度",null);
		append("制作组",null);
		exitCommand = new Command("退出",Command.EXIT,1);
		addCommand(exitCommand);
		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 commandAction(Command c ,Displayable d){
		
		if( c == List.SELECT_COMMAND){
			
			int index = getSelectedIndex();
			
			if(index != -1){
				
				if(!gameActive){
					
					index++;
				}
				
				/*根据菜单编号决定游戏状态*/
				switch(index){
				
				/*继续游戏*/
				case 0:
					
					midlet.menuListContinue();
					break;
				
				/*新游戏*/
				case 1:
					
					midlet.menuListNewGame();
					break;
				
				/*显示记录*/
				case 2:
					
					midlet.menuListRecord();
					break;
				
				/*显示游戏介绍*/
				case 3:
					
					midlet.menuListInstructions();
					break;
					
				default:
					
					break;
				}
			}
		}else if(c == exitCommand){
			
			midlet.menuListQuit();
		}
	}

	

}

⌨️ 快捷键说明

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