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

📄 gamechoice.java

📁 J2ME手机游戏,可以下下玩完,很好玩的.
💻 JAVA
字号:
package Src;

import javax.microedition.lcdui.*;
public class GameChoice extends Canvas implements Runnable{

	private int width,heigh;//获取不同机型长宽
	private Image imgBack,imgChoice;//定义背景图以及选择图
	private int img_X,img_Y;//选择图片启坐标	
	private FugitiveGame FugitiveGame;
	private boolean isStop;
	
	
	
	GameChoice(FugitiveGame FugitiveGame)
	{
		super.setFullScreenMode(true);
		try{
		imgBack=Image.createImage("/res/GameChoice.png");
		imgChoice=Image.createImage("/res/choice.png");
		}catch(Exception e){}
		width=this.getWidth();
		heigh=this.getHeight();
		img_X=38;img_Y=67;
		this.FugitiveGame=FugitiveGame;
		isStop=false;
	}
	
    public void keyPressed(int keycode)
    {
      int min_Y,max_Y;//最大最小移动高度
      int choice_i;//选者项
 	  if(keycode==-1)//向上
 	  {
 		min_Y=67;
  		img_Y=img_Y-12;
  		img_Y=Math.max(img_Y, min_Y);
  		this.repaint();
 	  }
 	  if(keycode==-2)//向下
 	  {
 		max_Y=115;
 		img_Y=img_Y+12;
 		img_Y=Math.min(img_Y, max_Y);
 		this.repaint();
 	  }
 	 if(keycode==-5)
	  {
 		choice_i=(img_Y-67)/12+1;
 		if(choice_i==4)
 		{
 		this.FugitiveGame.help();
 		isStop=true;
 		}
 		if(choice_i==3)
 		{
 		this.FugitiveGame.BestTime();
 		isStop=true;
 		}
 		if(choice_i==1)
 		{
 		this.FugitiveGame.Start();
 		isStop=true;
 		}
 	 
 	  }
 	  
    }
   
	
    public void run()
    {
    	while(!isStop)
    	{
    	this.repaint();
    	}
    }
    
	public void paint(Graphics g)
	{
		g.setColor(0xFFFFFF);
        g.fillRect( 0, 0, width,heigh );        
        g.setColor(0x00000);
        
        g.drawImage(imgBack,0,0, g.TOP | g.LEFT );
        
        g.drawImage(imgChoice,img_X,img_Y, g.TOP | g.LEFT );
         
	}

}

⌨️ 快捷键说明

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