📄 bosshead.java
字号:
package role;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JFrame;
import assistant.Music;
import frame.BossFrame;
/**
* Boss头类
* @author Administrator
*
*/
public class BossHead extends EnemyRole{
/**BOSS头图像*/
public static Image[][] bossHeadImage;
/**是否被击中*/
private boolean isHit;
/**被击中计数器*/
private int handCount;
/**是否播放音乐*/
private boolean isPlay = true;
/**
* 构造方法
* @param x X坐标
* @param y Y坐标
*/
public BossHead(int x, int y) {
super(x, y, 70, 70, 0, 0, 0);
this.life = 5;
}
@Override
/**
* 重写父类move()方法
*/
public void move() {
// TODO 自动生成方法存根
if(isHit){//被击中时,切换图片
this.img = bossHeadImage[0][1];
handCount++;
if(handCount>5){//自动切换为原始图片
isHit = false;
handCount = 0;
}
}
else{
this.img = bossHeadImage[0][0];
}
}
/**重写设置生命方法*/
public void setLife(int flyState){
super.setLife(flyState);
this.isHit = true;
}
/**
* Method: drawMyself
* Desctiptoin: 绘制自身图形
* @param g : 画笔
* @param jf : 窗体画布
*/
public void drawMyself(Graphics g,JFrame jf){
if(this.life == 0){
BossFrame.isWin = true;//胜利
if(isPlay){//播放音乐
BossFrame.playMusic.stopLoopMusic();
Music.playSingleMusic(Music.PLAY_WIN);
isPlay = false;
}
}
super.drawMyself(g, jf);
}
@Override
public int getPoint() {
// TODO 自动生成方法存根
return 10000;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -