JAVA实训新增功能

打印 上一主题 下一主题

主题 862|帖子 862|积分 2586

1.添加人物技能

主要代码

StaticValue.JAVA

点击查看代码
  1. public static List<BufferedImage> leftSkillImgs= new ArrayList<>();
  2. public static List<BufferedImage> rightSkillImgs = new ArrayList<>();
  3. //Static中
  4. for (int i = 0; i <=7; i++) {
  5.                 File rightfile = new File(ImagePath+"skill/right/"+i+".png");
  6.                 File leftfile = new File(ImagePath+"skill/left/"+i+".png");
  7.                 rightSkillImgs.add(ImageIO.read(rightfile));
  8.                 leftSkillImgs.add(ImageIO.read(leftfile));
复制代码
3.增加技能蓝条和利用次数

MyFrame.JAVA

点击查看代码
  1. protected List<BufferedImage> leftSkillImages;
  2. protected List<BufferedImage> rightSkillImages;
  3. //setImageList方法
  4.   leftSkillImages=StaticValue.leftSkillImgs.subList(0,7);
  5.   rightSkillImages=StaticValue.rightSkillImgs.subList(0,7);
  6. //新增skill方法
  7.   public void skill(){
  8.             if (this.status!=3&&this.status!=-3){
  9.                 if (this.status>0){
  10.                     this.status=6;
  11.                 }else{
  12.                     this.status=-6;
  13.                 }
  14.                 if (this.moving>=7){
  15.                     this.status= this.status>0?1:-1;
  16.                     this.y=235;
  17.              }
  18.         }
  19.     }
  20. //在run方法增加
  21. case 6:
  22. this.y=350;
  23. if (this.moving>7){
  24. this.moving=0;
  25. }   
  26. this.showImage=rightSkillImages.get((int)moving);
  27. moving+=0.5;
  28. if (this.moving>=7){
  29. this.status= this.status>0?1:-1;
  30. this.y=235;
  31. }
  32. break;
  33. case -6:
  34. this.y=350;
  35. if (this.moving>7){
  36. this.moving=0;
  37. }
  38. this.showImage=leftSkillImages.get((int)moving);
  39. moving+=0.5;
  40. if (this.moving>=7){
  41. this.status= this.status>0?1:-1;
  42. this.y=235;
  43. }
  44. break;
  45. //修改其中攻击敌人死亡的条件
  46. if (this.backGround !=null){
  47. List<Enemy> allEnemy = this.backGround.getAllEnemy();
  48. for (int i=0;i<allEnemy.size();i++){
  49. Enemy enemy = allEnemy.get(i);
  50. 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){
  51. enemy.dead();
  52. } 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) {
  53. enemy.dead();
  54.    }
  55.   }
  56. }
  57. //在move方法添加
  58. case 6:
  59. break;
  60. case -6:
  61. break;
复制代码
Person.JAVA

点击查看代码
  1. //在keyPressed中添加
  2. if (keyCode==74){
  3. this.person.attack();
  4. }
复制代码
具体效果实现

1.技能效果


2.敌人死亡倒地效果


3.蓝条利用效果



免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

用户国营

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表