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

📄 winchip.java

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

import java.awt.Image;

import assistant.PublicVar;
import assistant.MoveImageChange;

/**
 * 本类为胜利松鼠类
 * @author Administrator
 *
 */
public class WinChip extends SportRole {
	/** 图片切换对象 */
	private MoveImageChange moveImageChange = new MoveImageChange(20);

	/** 图片快速切换对象 */
	private MoveImageChange moveLoveImageChange = new MoveImageChange(5);
	
	/**松鼠移动图像数组*/
	private Image[] moveRightImage = { Chip.chipImage[0][1],
			Chip.chipImage[0][2], Chip.chipImage[0][3] };

	/** 移动计数器 */
	private int moveCount;

	/** 是否站立 */
	private boolean isStand;

	/** 花角色 */
	private FlowerHart flowerHart;

	/** 是否停止 */
	private boolean isStop;

	/**
	 * 构造方法
	 * @param x
	 *            X坐标
	 * @param y   Y坐标
	 * @param state
	 *            松鼠状态
	 */
	public WinChip(int x, int y, int state) {
		super(x, y, 40, 40, state);
	}

	@Override
	/**
	 * 重写父类move()方法
	 */
	public void move() {

		if (FlowerHart.isStop == false) {//花是否停止动作
			if (this.isStand == false) {//移动
				this.setStand();
			}
			else {//站立
				if (Dale.flowerHart != null && Dale.flowerHart.isShow) {
					this.flowerHart.setState(1);
				}

			}
		}
		else {
			this.runToDale();

		}

	}
	
	/**
	 * 奔向女松鼠
	 *
	 */
	private void runToDale(){
		if (isStop == false) {//未停止动作
			this.img = moveLoveImageChange.imageChange(moveRightImage);
			this.x += 3;
			
			/*坐标大于280则站立*/
			if (this.x > 280) {
				this.x = 280;
				this.img = Chip.chipImage[0][2];
				this.isStop = true;
			}
		}
	}
	
	/**
	 * 设置站立状态
	 *
	 */
	private void setStand(){
		this.img = moveImageChange.imageChange(moveRightImage);
		moveCount++;
		if (moveCount == 3) {//移动
			this.x += 1;
			moveCount = 0;
		}
		
		if (this.x > 200) {//坐标大于200,则站立
			this.x = 200;
			this.isStand = true;
			this.img = Chip.chipImage[0][0];
			
			/*产生花心对象*/
			this.flowerHart = new FlowerHart(this.x - 30, this.y - 100, true);
			PublicVar.roleList.add(flowerHart);
		}
	}
}

⌨️ 快捷键说明

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