📄 dale.java
字号:
package role;
import java.awt.Image;
import assistant.PublicVar;
import assistant.MoveImageChange;
/**
* 本类为女松鼠类
* @author Administrator
*
*/
public class Dale extends SportRole {
/**女松鼠图像数组*/
public static Image[][] daleImage;
/** 图片切换对象 */
private MoveImageChange moveImageChange = new MoveImageChange(20);
/** 图片快速切换对象 */
private MoveImageChange moveLoveImageChange = new MoveImageChange(5);
/**是否下落*/
private boolean isDown = true;
/**女松鼠移动数组*/
private Image[] moveLeftImage = {Dale.daleImage[0][0],
Dale.daleImage[0][1], Dale.daleImage[0][2]};
/**是否站立*/
private boolean isStand;
/** 是否停止 */
private boolean isStop;
/**是否产生花心*/
private boolean isCreateFlower = true;
/**花角色*/
public static FlowerHart flowerHart;
/**下落计数器*/
private int count;
/**
* 构造方法
*
* @param x X坐标
* @param y Y坐标
*/
public Dale() {
super(530, -70, 40, 40, 0);
this.img = daleImage[0][1];
}
@Override
/**
* 重写父类move()方法
*/
public void move() {
if (FlowerHart.isStop == false) {//花心没有停止动作
if(isDown){//是否向下
this.setDown();
}
else{//不再向下
if(this.isStand){//是否站立
this.stand();
}
else{//行走
this.walk();
}
}
}
else {//花心停止
this.runToChip();
}
}
/**
* 奔向男松鼠
*
*/
private void runToChip(){
if (isStop == false) {
this.img = moveLoveImageChange.imageChange(moveLeftImage);
this.x -= 3;
if (this.x < 320) {
this.x = 320;
this.img = Dale.daleImage[0][2];
this.isStop = true;
}
}
}
/**
* 行走方法
*
*/
private void walk(){
this.img = moveImageChange.imageChange(moveLeftImage);
this.x-=1;
if(this.x<400){//当角色x坐标小于400,进行站立
this.x = 400;
this.isStand = true;
}
}
/**
* 站立方法
*
*/
private void stand(){
this.img = Dale.daleImage[0][3];
//产生花
if(isCreateFlower){
flowerHart = new FlowerHart(this.x-30,this.y-100,false);
PublicVar.roleList.add(flowerHart);
isCreateFlower = false;
}
if(flowerHart.isShow){//当花完全显示时,移动
flowerHart.setState(1);
}
}
/**
* 设置下落状态
*
*/
private void setDown(){
count++;
if(count>1){//2毫秒移动一次
this.y+=1;
count=0;
}
if(this.y>500){//Y坐标大于500,停止下落
this.y = 500;
this.isDown = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -