📄 bosshand.java
字号:
package role;
import java.awt.Image;
import frame.BossFrame;
import assistant.PublicVar;
/**
* Boss手类
* @author Administrator
*
*/
public class BossHand extends EnemyRole {
/**Boss手图片*/
public static Image[][] handImage;
/**是否处于发射子弹状态*/
private boolean isFire;
/**手张开计数器*/
private int handCount;
/**子弹产生计数器*/
private int count;
/**
* 构造方法
* @param x X坐标
* @param y Y坐标
* @param width 宽度
* @param height 高度
* @param state 状态
*/
public BossHand(int x, int y, int width, int height, int state) {
super(x, y, width, height, state, 120, 0);
this.life = 3;
}
@Override
/**
* 重写父类move方法
*/
public void move() {
if(BossFrame.isWin == false){//如果未过关
this.setImage();//设置图片
if(isFire){//手作张开状
handCount++;
if(handCount>10){//手张开时间
isFire = false;
handCount = 0;
}
}
this.createBullte();//产生子弹
}
}
/**
* 设置图片
*a
*/
private void setImage(){
if(this.state == PublicVar.RIGHT){//向右
if(isFire){
this.img = handImage[1][1];
}
else{
this.img = handImage[1][0];
}
}
else{//向左
if(isFire){
this.img = handImage[0][0];
}
else{
this.img = handImage[0][1];
}
}
}
/**
* 产生子弹
*
*/
protected void createBullte(){
if(count>frequency && this.life != 0){//当计数器大于子弹产生频率时,产生子弹
int tempy=0;
tempy=y+height/2;
PublicVar.roleList.add(new EnemyBullet(x+width/2,tempy,state,2));
count=0;
isFire=true;
}
count++;
}
@Override
public int getPoint() {
// TODO 自动生成方法存根
return 6000;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -