| 
本帖最后由 taroxd 于 2013-11-9 19:05 编辑
x
加入我们,或者,欢迎回来。您需要 登录 才可以下载或查看,没有帐号?注册会员  
 新手几乎没有编程基础,只会瞎改改。RGSS3的书写规范也不是很清楚。如果看到有问题,希望能不吝赐教!
 
 1.修改自这里的脚本,使得只显示HP条,且地图上HP发生变化时可以及时更新。问一下,这样判断是否合理?
 
 #============================================================================#  〇 地图显示血条#============================================================================class Scene_Map < Scene_Base  #--------------------------------------------------------------------------  # ● 开始处理  #--------------------------------------------------------------------------  alias hp_window_start start  def start    hp_window_start    @hp_window = Window_hp.new    @hp_window.refresh    @hp_window.hide  end  alias hp_window_update update  def update    hp_window_update    @hp_window.refresh if @hp_window.need_refresh?    @hp_window.visible = true#~     @hp_window.visible = $game_switches[1] #控制开关  endend class Window_hp < Window_Base  #--------------------------------------------------------------------------  # ● 初始化对象  #--------------------------------------------------------------------------  def initialize    @party_hp_rate = []    super(-12, -16, 544 + 12, 416 + 16)    self.opacity = 0    update  end  #--------------------------------------------------------------------------  # ● 绘制 HP   #--------------------------------------------------------------------------  def notext_draw_actor_hp(actor, x, y, width = 124)    draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)    change_color(system_color)  end  #--------------------------------------------------------------------------  # ● 绘制全队 HP  #--------------------------------------------------------------------------  def notext_draw_party_hp    $game_party.all_members.each_with_index do |actor, i|      notext_draw_actor_hp(actor, 0, 16 * i)     end  end  #--------------------------------------------------------------------------  # ● 获取全队 HP 的比率  #--------------------------------------------------------------------------  def party_hp_rate    $game_party.all_members.collect {|actor| actor.hp_rate}  end  #--------------------------------------------------------------------------  # ● 刷新  #--------------------------------------------------------------------------  def refresh    contents.clear    notext_draw_party_hp    @party_hp_rate = party_hp_rate  end  #--------------------------------------------------------------------------  # ● 判定是否需要刷新  #--------------------------------------------------------------------------  def need_refresh?    !(party_hp_rate == @party_hp_rate)  endend
#============================================================================ 
#  〇 地图显示血条 
#============================================================================ 
class Scene_Map < Scene_Base 
  #-------------------------------------------------------------------------- 
  # ● 开始处理 
  #-------------------------------------------------------------------------- 
  alias hp_window_start start 
  def start 
    hp_window_start 
    @hp_window = Window_hp.new 
    @hp_window.refresh 
    @hp_window.hide 
  end 
  alias hp_window_update update 
  def update 
    hp_window_update 
    @hp_window.refresh if @hp_window.need_refresh? 
    @hp_window.visible = true 
#~     @hp_window.visible = $game_switches[1] #控制开关 
  end 
end 
  
class Window_hp < Window_Base 
  #-------------------------------------------------------------------------- 
  # ● 初始化对象 
  #-------------------------------------------------------------------------- 
  def initialize 
    @party_hp_rate = [] 
    super(-12, -16, 544 + 12, 416 + 16) 
    self.opacity = 0 
    update 
  end 
  #-------------------------------------------------------------------------- 
  # ● 绘制 HP  
  #-------------------------------------------------------------------------- 
  def notext_draw_actor_hp(actor, x, y, width = 124) 
    draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) 
    change_color(system_color) 
  end 
  #-------------------------------------------------------------------------- 
  # ● 绘制全队 HP 
  #-------------------------------------------------------------------------- 
  def notext_draw_party_hp 
    $game_party.all_members.each_with_index do |actor, i| 
      notext_draw_actor_hp(actor, 0, 16 * i)  
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● 获取全队 HP 的比率 
  #-------------------------------------------------------------------------- 
  def party_hp_rate 
    $game_party.all_members.collect {|actor| actor.hp_rate} 
  end 
  #-------------------------------------------------------------------------- 
  # ● 刷新 
  #-------------------------------------------------------------------------- 
  def refresh 
    contents.clear 
    notext_draw_party_hp 
    @party_hp_rate = party_hp_rate 
  end 
  #-------------------------------------------------------------------------- 
  # ● 判定是否需要刷新 
  #-------------------------------------------------------------------------- 
  def need_refresh? 
    !(party_hp_rate == @party_hp_rate) 
  end 
end 
 |