查看: 3799|回复: 7

[已经解决] 敌人血条位置的问题

[复制链接]
梦石
0
星屑
2245
在线时间
1015 小时
注册时间
2015-10-17
回帖
1077
发表于 2020-4-17 21:35:48 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

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

×
问下,如何把这个脚本的血条位置移动到怪物左边,上面再加个怪物名字,MP显示去掉,就是图片1的显示,变成图片2那样的,知道的指点下,谢谢

[pre lang="ruby"]#==============================================================================
# 功能:战斗中显示敌人血和蓝于敌人脚下
# 适用:RMVX Ace
# 作者:殇殃 2012.3.10
# 使用方法:复制整个脚本插入到Main之前
# 注意:由于血条是显示在敌人脚下,所以敌群的位置不能太靠底部,不然会被挡住。
#       可以自行更改坐标修改显示位置、血条的颜色等。
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  游戏中全部窗口的超级类。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● 描绘敌人HP
  #--------------------------------------------------------------------------
  def draw_enemy_hp(enemy, x, y, width = 80)
    draw_gauge(x, y, width, enemy.hp_rate, hp_gauge_color1, hp_gauge_color2)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 30, line_height, Vocab::hp_a)
    self.contents.font.color = hp_color(enemy)
    self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.hp, 2)
    #一个数字占16像素
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人MP
  #--------------------------------------------------------------------------
  def draw_enemy_mp(enemy, x, y, width = 80)
    draw_gauge(x, y, width, enemy.mp_rate, mp_gauge_color1, mp_gauge_color2)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 30, line_height, Vocab::mp_a)
    self.contents.font.color = mp_color(enemy)
    self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.mp, 2)
  end
end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  战斗显示用活动块。Game_Battler 类的实例监视、
# 活动块的状态的监视、活动块状态自动变化。
#==============================================================================

class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #     viewport : 视区
  #     battler  : 战斗者 (Game_Battler)
  #--------------------------------------------------------------------------
  def initialize(viewport, battler = nil)
    super(viewport)
    @battler = battler
    @battler_visible = false
    @effect_type = nil      
    @effect_duration = 0   
    if @battler.is_a?(Game_Enemy)
      width = 24 + 80 #边距12*2+血条的长度(在draw_enemy_hp中定义)
      height = 24 + 24*2 #边距12*2+line_height*2
      x = @battler.screen_x - width/2 #screen_x是怪物图片水平方向上的中点位置
      y = @battler.screen_y - 12 #边距12,显示HP/MP的窗口无边框
      @enemy_hpmp_window = Window_Base.new(x, y, width, height)
      @enemy_hpmp_window.opacity = 0
      @enemy_hpmp_window.contents = Bitmap.new(width - 24, height - 24)#位图比窗口小24像素取消边框
      @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
      @old_hp = -1
      @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
      @old_mp = -1
    end
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
      @enemy_hpmp_window.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    if @battler == nil
      self.bitmap = nil
    else
      @use_sprite = @battler.use_sprite?
      if @use_sprite
        update_bitmap
        update_origin
        update_position
      end
      setup_new_effect
      setup_new_animation
      update_effect
      if @enemy_hpmp_window != nil and (@old_hp != @battler.hp or @old_mp != @battler.mp)
        if @battler.hp == 0
          @enemy_hpmp_window.hide
        else
          @enemy_hpmp_window.contents.clear
          @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
          @old_hp = @battler.hp
          @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
          @old_mp = @battler.mp
          @enemy_hpmp_window.show #怪物死后再被复活
        end #if battler.hp == 0
      end
    end #if @battler == nil
  end

end
[/pre]
55555555.png
6666666.jpg
梦石
0
星屑
1877
在线时间
220 小时
注册时间
2018-8-5
回帖
75
发表于 2020-4-17 22:08:00 | 显示全部楼层
显示血条和名字的脚本很多,一搜一大片吧
一点一点加油
回复

使用道具 举报

头像被屏蔽
梦石
0
星屑
5706
在线时间
922 小时
注册时间
2013-8-29
回帖
1401
发表于 2020-4-17 22:23:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

梦石
0
星屑
2245
在线时间
1015 小时
注册时间
2015-10-17
回帖
1077
 楼主| 发表于 2020-4-17 22:29:32 | 显示全部楼层
嗯,这个脚本,添个怪物名字在上面,这个就不会了
回复

使用道具 举报

头像被屏蔽
梦石
0
星屑
5706
在线时间
922 小时
注册时间
2013-8-29
回帖
1401
发表于 2020-4-17 22:43:48 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

梦石
2
星屑
6767
在线时间
501 小时
注册时间
2018-3-23
回帖
487

R考场第七期银奖

发表于 2020-4-17 22:56:09 | 显示全部楼层
  1. #==============================================================================
  2. # 功能:战斗中显示敌人血和蓝于敌人脚下
  3. # 适用:RMVX Ace
  4. # 作者:殇殃 2012.3.10
  5. # 使用方法:复制整个脚本插入到Main之前
  6. # 注意:由于血条是显示在敌人脚下,所以敌群的位置不能太靠底部,不然会被挡住。
  7. #       可以自行更改坐标修改显示位置、血条的颜色等。
  8. #==============================================================================
  9. # ■ Window_Base
  10. #------------------------------------------------------------------------------
  11. #  游戏中全部窗口的超级类。
  12. #==============================================================================

  13. class Window_Base < Window
  14.   #--------------------------------------------------------------------------
  15.   # ● 描绘敌人HP
  16.   #--------------------------------------------------------------------------
  17.   def draw_enemy_hp(enemy, x, y, width = 80)
  18.     draw_gauge(x, y, width, enemy.hp_rate, hp_gauge_color1, hp_gauge_color2)
  19.     self.contents.font.color = system_color
  20.     self.contents.draw_text(x, y, 30, line_height, Vocab::hp_a)
  21.     self.contents.font.color = hp_color(enemy)
  22.     self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.hp, 2)
  23.     #一个数字占16像素
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 绘制敌人MP
  27.   #--------------------------------------------------------------------------
  28.   def draw_enemy_mp(enemy, x, y, width = 80)
  29.     draw_gauge(x, y, width, enemy.mp_rate, mp_gauge_color1, mp_gauge_color2)
  30.     self.contents.font.color = system_color
  31.     self.contents.draw_text(x, y, 30, line_height, Vocab::mp_a)
  32.     self.contents.font.color = mp_color(enemy)
  33.     self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.mp, 2)
  34.   end
  35. end
  36. #==============================================================================
  37. # ■ Sprite_Battler
  38. #------------------------------------------------------------------------------
  39. #  战斗显示用活动块。Game_Battler 类的实例监视、
  40. # 活动块的状态的监视、活动块状态自动变化。
  41. #==============================================================================

  42. class Sprite_Battler < Sprite_Base
  43.   #--------------------------------------------------------------------------
  44.   # ● 初始化对象
  45.   #     viewport : 视区
  46.   #     battler  : 战斗者 (Game_Battler)
  47.   #--------------------------------------------------------------------------
  48.   def initialize(viewport, battler = nil)
  49.     super(viewport)
  50.     @battler = battler
  51.     @battler_visible = false
  52.     @effect_type = nil      
  53.     @effect_duration = 0   
  54.     if @battler.is_a?(Game_Enemy)
  55.       width = 24 + 80
  56.       height = 24 + 24 * 3
  57.       x = @battler.screen_x - 12 - width * 3 / 2
  58.       y = @battler.screen_y - 12 - height / 2
  59.       @enemy_hpmp_window = Window_Base.new(x, y, width, height)
  60.       @enemy_hpmp_window.opacity = 0
  61.       @enemy_hpmp_window.contents = Bitmap.new(width - 24, height - 24)
  62.       @enemy_hpmp_window.draw_text_ex(0, 0, @battler.name)
  63.       @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 24)
  64.       @old_hp = -1
  65.       @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 48)
  66.       @old_mp = -1
  67.     end
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 释放
  71.   #--------------------------------------------------------------------------
  72.   def dispose
  73.     if self.bitmap != nil
  74.       self.bitmap.dispose
  75.       @enemy_hpmp_window.dispose
  76.     end
  77.     super
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 更新画面
  81.   #--------------------------------------------------------------------------
  82.   def update
  83.     super
  84.     if @battler == nil
  85.       self.bitmap = nil
  86.     else
  87.       @use_sprite = @battler.use_sprite?
  88.       if @use_sprite
  89.         update_bitmap
  90.         update_origin
  91.         update_position
  92.       end
  93.       setup_new_effect
  94.       setup_new_animation
  95.       update_effect
  96.       if @enemy_hpmp_window != nil and (@old_hp != @battler.hp or @old_mp != @battler.mp)
  97.         if @battler.hp == 0
  98.           @enemy_hpmp_window.hide
  99.         else
  100.           @enemy_hpmp_window.contents.clear
  101.           @enemy_hpmp_window.draw_text_ex(0, 0, @battler.name)
  102.           @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 24)
  103.           @old_hp = @battler.hp
  104.           @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 48)
  105.           @old_mp = @battler.mp
  106.           @enemy_hpmp_window.show #怪物死后再被复活
  107.         end #if battler.hp == 0
  108.       end
  109.     end #if @battler == nil
  110.   end

  111. end
复制代码

点评

fjm
非常感谢,可以用了  发表于 2020-4-17 23:02

评分

参与人数 2赞 +2 收起 理由
PLeaseS + 1 塞糖
fjm + 1 认可答案

查看全部评分

祝好。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部