1.添加人物技能
主要代码
StaticValue.JAVA
点击查看代码- public static List<BufferedImage> leftSkillImgs= new ArrayList<>();
- public static List<BufferedImage> rightSkillImgs = new ArrayList<>();
- //Static中
- for (int i = 0; i <=7; i++) {
- File rightfile = new File(ImagePath+"skill/right/"+i+".png");
- File leftfile = new File(ImagePath+"skill/left/"+i+".png");
- rightSkillImgs.add(ImageIO.read(rightfile));
- leftSkillImgs.add(ImageIO.read(leftfile));
复制代码 3.增加技能蓝条和利用次数
MyFrame.JAVA
点击查看代码- protected List<BufferedImage> leftSkillImages;
- protected List<BufferedImage> rightSkillImages;
- //setImageList方法
- leftSkillImages=StaticValue.leftSkillImgs.subList(0,7);
- rightSkillImages=StaticValue.rightSkillImgs.subList(0,7);
- //新增skill方法
- public void skill(){
- if (this.status!=3&&this.status!=-3){
- if (this.status>0){
- this.status=6;
- }else{
- this.status=-6;
- }
- if (this.moving>=7){
- this.status= this.status>0?1:-1;
- this.y=235;
- }
- }
- }
- //在run方法增加
- case 6:
- this.y=350;
- if (this.moving>7){
- this.moving=0;
- }
- this.showImage=rightSkillImages.get((int)moving);
- moving+=0.5;
- if (this.moving>=7){
- this.status= this.status>0?1:-1;
- this.y=235;
- }
- break;
- case -6:
- this.y=350;
- if (this.moving>7){
- this.moving=0;
- }
- this.showImage=leftSkillImages.get((int)moving);
- moving+=0.5;
- if (this.moving>=7){
- this.status= this.status>0?1:-1;
- this.y=235;
- }
- break;
- //修改其中攻击敌人死亡的条件
- if (this.backGround !=null){
- List<Enemy> allEnemy = this.backGround.getAllEnemy();
- for (int i=0;i<allEnemy.size();i++){
- Enemy enemy = allEnemy.get(i);
- if (this.status ==4 && (this.x + 125)>enemy.getX() && (this.x+125)<enemy.getX()+250||this.status ==6 && (this.x + 125)>enemy.getX() && (this.x+125)<enemy.getX()+250){
- enemy.dead();
- } else if (this.status ==-4 &&(this.x+125)<(enemy.getX()+400)&&(this.x+125)>enemy.getX()+256||this.status ==-6 &&(this.x+125)<(enemy.getX()+400)&&(this.x+125)>enemy.getX()+256) {
- enemy.dead();
- }
- }
- }
- //在move方法添加
- case 6:
- break;
- case -6:
- break;
复制代码 Person.JAVA
点击查看代码- //在keyPressed中添加
- if (keyCode==74){
- this.person.attack();
- }
复制代码 具体效果实现
1.技能效果
2.敌人死亡倒地效果
3.蓝条利用效果
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |