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

📄 menulist.java

📁 MIDP 2.0 下的一个打飞机的例子,主要是运用了2.0中比1.0多出来的GameCanvas类,还Game包,通过这个例子可以总结一下MIDP2.0比1.0在开发游戏方面的优势.
💻 JAVA
字号:
package hawk;

import javax.microedition.lcdui.*;


class MenuList
    extends List
    implements CommandListener
{
    private HawkMIDlet midlet;
    private Command exitCommand;
    private boolean gameActive = false;


    MenuList(HawkMIDlet midlet)
    {
        super("Hawk", List.IMPLICIT);
        this.midlet = midlet;

        append("New game", null);
        append("Instructions", null);

        exitCommand = new Command("Exit", Command.EXIT, 1);
        addCommand(exitCommand);

        setCommandListener(this);
    }


    void setGameActive(boolean active)
    {
        if (active && !gameActive)
        {
            gameActive = true;
            insert(0, "Continue", 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:   // Instructions
                    midlet.menuListInstructions();
                    break;
                default:
                    // can't happen
                    break;
                }
            }
        }
        else if (c == exitCommand)
        {
            midlet.menuListQuit();
        }
    }
}

⌨️ 快捷键说明

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