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

📄 gamefly.java

📁 智益类游戏
💻 JAVA
字号:
import java.io.IOException;
import java.util.Random;

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;


public class gameFly extends Sprite {
	private static final int BA=0;
	private static final int BB=1;
	private static final int BC=2;

	private int m_State;
	private int x,y;
	private static Random rand=new Random();
	private static Image Img;
	static{
		try {
			Img=Image.createImage("/res/flyobj.png");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	 private  int[] ba={0,1,2};
	 private int[] bb={4,5,6,7};
	 private int[] bc={8,9,10,11};
	
	public gameFly() {
		super(Img, 16, 16);
		int tmp=Math.abs(rand.nextInt())%3;
		switch(tmp){
		case 0:
			m_State=BA;
			this.setFrameSequence(ba);
			break;
		case 1:
			m_State=BB;
			this.setFrameSequence(bb);
			break;
		case 2:
			m_State=BC;
			this.setFrameSequence(bc);
			break;
		}
		
		
		
		y=20;
		x=10+Math.abs(rand.nextInt())%140;
		this.setPosition(x, y);
	}
	public void down(){
		y+=2;
		this.setPosition(x, y);
		
	}
	public boolean isBottom(){
	    if(y>200)
	    	return true;
	    else
	    	return false;
	}
	
	
	public void doOnChar(gameChar gc){
		switch(m_State){
		case BA:
			gc.setCharLife(false);
			break;
		case BB:
			gc.setGameStatus(gameChar.GAME_STATUS_CONF);
			break;
		case BC:
			gc.setGameStatus(gameChar.GAME_STATUS_SPEEDUP);
			
			break;
		}
		
	}
	

}

⌨️ 快捷键说明

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