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

📄 gamestart.java

📁 j2me游戏 j2me游戏j2me游戏j2me游戏j2me游戏j2me游戏j2me游戏
💻 JAVA
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
 * @author  JimmyLiu
 */
public class gameStart extends MIDlet implements CommandListener{
        public Alert logo;   //logo屏幕
        public Form about;   //关于画面
        public Form help;    //帮助画面
        public List menu;    //菜单画面
        /**
		 * @uml.property  name="mc"
		 * @uml.associationEnd  
		 */
        public gameScreen mc;//游戏画面
        public Display display;//屏幕控制对象
        public Command c1;  //确定、返回命令
		public Command c2;
        public Command cback;  //返回游戏命令
        /**
		 * @uml.property  name="midlet"
		 * @uml.associationEnd  
		 */
        public static  gameStart midlet; //全局实例对象
        public gameStart()
         {midlet=this;
         display=Display.getDisplay(this);
         c1=new Command("确定",Command.BACK,1);
         c2=new Command("返回",Command.SCREEN,1);
         setLogo();
         setAbout();
         setHelp();
        
         mc=new gameScreen();
         setMenu();
         
        }
  public void setMenu(){
	  menu=new List("疯狂水果",List.IMPLICIT);
      menu.addCommand(c1);

      menu.append("新游戏",null);
      menu.append("游戏帮助",null);
      menu.append("关于",null);
      menu.append("退出",null);
      menu.setCommandListener(this);
        }
  public void setLogo(){
	  logo=new Alert("");
      logo.setTimeout(5000);
      Image im=loadImage("/logo.png");
      logo.setImage(im);
      logo.setType(AlertType.INFO); 	
   }
  public void setAbout(){
	  String aboutInfo="深圳市XX科技有限公司"+
      "\n客服电话:010-65280XXX"+
      "\n客服信箱:service@XXX.com.cn"+
      "\n内容提供"+
      "\n北京XXXX科技发展有限公司";
	  about=new Form("关于我们");
	  about.append(aboutInfo);
	  about.addCommand(c2);
	  about.setCommandListener(this);
  }
  public void setHelp(){
	  help=new Form("游戏帮助");
      String helpinfo="熊猫卡卡是一个爱吃水果的小朋\n"
                    +"友,突然一天夜里他梦到他最喜\n"
                    +"欢的水果全都飞上了天,为了能\n"
                    +"够将水果抓回来,卡卡找到了一\n"
                    +"条非常长的绳子,对准了正在飞\n"
                    +"行的水果抛了过去,终于通过\n"
                    +"卡卡的努力,所有的水果都\n"
                    +"回来了……\n"
                    +"方向键左或数字4键 向左跑动\n"
                    +"发射键或数字5键	攻击\n"
                    +"方向键右或数字6键 向右跑动\n"
                    +"数字3键	切换道具\n"
                    +"数字1键	使用道具\n";

      help.append(helpinfo);
      help.addCommand(c2);
      help.setCommandListener(this);
  }
   public static Image loadImage(String fname)
   { Image im=null;
     try{
      im=Image.createImage(fname);
     }catch(Exception e){
      System.out.println("pic err fname="+fname);
     }
     return im;
   }
   public void startApp()
   {
            display.setCurrent(logo,menu);
   }
   public void pauseApp()
   {}
   public void destroyApp(boolean f)
   {}

   public void commandAction(Command arg0, Displayable arg1) {
        if(arg0==c1)
        {       if(menu.getString(menu.getSelectedIndex()).equals("退出"))
                {      this.notifyDestroyed();
                        }
                if(menu.getString(menu.getSelectedIndex()).equals("游戏帮助"))
                {
                        display.setCurrent(help);
                }
                if(menu.getString(menu.getSelectedIndex()).equals("关于"))
                {
                      display.setCurrent(about);
                }
                if(menu.getString(menu.getSelectedIndex()).equals("新游戏"))
                {     mc.initLevel(1);
                      display.setCurrent(mc);
                }
                if(menu.getString(menu.getSelectedIndex()).equals("返回游戏"))
                {    //去掉等待的时间 得到剩下的时间的开始时间
                	  mc.levellastTime+=(System.currentTimeMillis()-mc.waitTime)/1000;
                      display.setCurrent(mc);
                      mc.gameState=gameScreen.GAME;
                      menu.delete(0);
                }

                }
        if(arg0==c2)
        {
                this.display.setCurrent(menu);
        }
 }
}

⌨️ 快捷键说明

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