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

📄 gamemidlet.java

📁 用Java语言实现的泡泡堂小游戏精简版。
💻 JAVA
字号:
import javax.microedition.midlet.* ;
import javax.microedition.lcdui.* ;
public class GameMIDlet extends MIDlet
implements CommandListener
{
        /*定义舞台*/
        Display display ;
        private Server server;
        private Client client;
        private static final String SERVER = "Server";
        private static final String CLIENT = "Client";
        /*定义选择画面*/
        private static final String[] names = {SERVER, CLIENT};
        private Form f;
        private ChoiceGroup cg;
        Command c1,exitCommand;
        public GameMIDlet()
        {       exitCommand = new Command("exit", Command.EXIT,2);
                 c1=new Command("结束", Command.EXIT, 1);
                display = Display.getDisplay(this) ;
        }
        /*初始化选择画面*/
        public void begin()
        { f = new Form("泡泡车");
                        cg = new ChoiceGroup("请选择类型",Choice.EXCLUSIVE, names, null);
                        f.append(cg);
                        f.addCommand(new Command("开始", Command.OK, 1));
                        f.addCommand(c1);
                        f.setCommandListener(this);
                        display.setCurrent(f);
        }
        public void startApp()
        {
         begin();              
                
        }
        /*按键事件监听*/
        public void commandAction(Command c,Displayable s)
        {
                String cmd = c.getLabel() ;
                if(cmd.equals("开始"))
                {
                  String name = cg.getString(cg.getSelectedIndex());
                  if (name.equals(SERVER)) {
                   server = new Server(this);
                   server.start();
                }
                else {
            	client = new Client(this);
                client.start();
            }
            }else if(cmd.equals("结束"))
                {
                        notifyDestroyed() ;
                }
               else if(cmd.equals("Exit"))
	          {if (server != null) {
                    server.stop();
                    }
                if (client != null) {
                    client.stop();
                }
                begin();
            }

        }
        public void pauseApp()
        {

        }
        public void destroyApp(boolean unconditional)
        {
        }
}

⌨️ 快捷键说明

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