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

📄 fire.java

📁 简单的用Java做的小游戏主要是用了自己的框架来
💻 JAVA
字号:
package role;

import java.awt.Image;

import assistant.PublicVar;
import assistant.MoveImageChange;

/**
 * 移动火类
 * @author Administrator
 *
 */
public class Fire extends SportRole{
	/**火图像数组*/
	public static Image[][] fireImage;
	
	/**图像切换对象*/
	private MoveImageChange moveChange = new MoveImageChange(2);
	
	/**图像切换数组*/
	private  Image[] moveImage= new Image[]{fireImage[0][0],
			fireImage[0][1],fireImage[0][2],fireImage[0][3]};
	
	/**是否向右移*/
	private boolean isRight;
	
	/**移动距离计数器*/
	private int moveCount;
	
	/**移动计数器*/
	private int count;
	/**
	 * 构造方法
	 * @param x X坐标
	 * @param y Y坐标
	 * @param state 起始状态
	 * @param count 移动计数器
	 */
	public Fire(int x, int y, int state,int moveCount) {
		super(x, y, 40, 92, state);
		this.speed = 4;
		
		if(state == PublicVar.RIGHT){//起始时向右移
			isRight = true;
		}
		
		this.moveCount = moveCount;
	}

	@Override
	public void move() {
		// TODO 自动生成方法存根
		this.img = moveChange.imageChange(moveImage);
		
		if(isRight){//向右移
			x += this.speed;
			this.state = PublicVar.RIGHT;
		}
		else{//向左移
			x -= this.speed;
			this.state = PublicVar.LEFT;
		}
		
		if(count == moveCount){//切换方向
			count = 0;
			isRight = !isRight;
		}
		
		count++;
	}


}

⌨️ 快捷键说明

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