Project1

标题: 显示敌人血槽 [打印本页]

作者: 200878242    时间: 2008-11-18 05:10
标题: 显示敌人血槽
显示敌人血槽,可以在血槽上加上生命多少吗如:520/840脚本如下:
[HTMLICON_STATE_IDS = 5..18

#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  游戏中全部窗口的超级类。
#==============================================================================

class Window_Base < Window
#--------------------------------------------------------------------------
# ● 描绘状态
#     actor : 角色
#     x     : 描画目标 X 坐标
#     y     : 描画目标 Y 坐标
#     width : 描画目标的宽
#--------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 120)
  state_size = 0
  for state in actor.states
    # 图标数量超出宽度就中断循环
    if state_size >= width / 16
      break
    end
    # 此状态不带图标就跳过
    if !ICON_STATE_IDS.include?(state)
      next
    end
    bitmap = RPG::Cache.icon($data_states[state].name + "_sta.png")
    if actor.states_turn[state] >= $data_states[state].hold_turn/2
      opacity = 255
    else
      opacity = 100
    end
    # 这里的图标大小默认是16x16,要改就改下面那个Rect.new(0, 0, 16, 16)
    self.contents.blt(x + 16 * state_size, y + 32, bitmap, Rect.new(0, 0, 16, 16), opacity)
    state_size += 1
  end
end
end
  
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
# 重新定义的内容,可以显示敌人的HP百分比
# 作者:carol3_柳柳
#==============================================================================

class Window_Help < Window_Base
  def set_enemy(actor)
    self.width = 240
    self.x = 210
    self.y = 144
    self.contents.clear
    carol3_draw_hp_bar(actor, 0, 0)
    draw_actor_name(actor, 0, 0)
    draw_enemy_state(actor, 0, 32)
    @text = nil
    self.visible = true
  end
  def carol3_draw_hp_bar(actor, x, y, width = 118) #宽度可调
    self.contents.font.color = system_color
    self.contents.fill_rect(x-1, y+17, width+2,6, Color.new(0, 0, 0, 255))
    w = width * actor.hp / actor.maxhp
    self.contents.fill_rect(x, y+18, w,1, Color.new(255, 96, 96, 255))
    self.contents.fill_rect(x, y+19, w,1, Color.new(255, 0, 0, 255))
    self.contents.fill_rect(x, y+20, w,1, Color.new(128, 0, 0, 255))
    self.contents.fill_rect(x, y+21, w,1, Color.new(0, 0, 0, 255))
    self.contents.font.color = normal_color
  end


#--------------------------------------------------------------------------
[/code]
轩辕剑菜单怎么在角色旁边加血槽
[LINE]1,#dddddd[/LINE]此贴于 2008-11-18 12:24:57 被版主darkten提醒,请楼主看到后对本贴做出回应。 [LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: clap_pl    时间: 2008-11-18 05:22
这一段
def carol3_draw_hp_bar(actor, x, y, width = 118) #宽度可调
   self.contents.font.color = system_color
   self.contents.fill_rect(x-1, y+17, width+2,6, Color.new(0, 0, 0, 255))
   w = width * actor.hp / actor.maxhp
   self.contents.fill_rect(x, y+18, w,1, Color.new(255, 96, 96, 255))
   self.contents.fill_rect(x, y+19, w,1, Color.new(255, 0, 0, 255))
   self.contents.fill_rect(x, y+20, w,1, Color.new(128, 0, 0, 255))
   self.contents.fill_rect(x, y+21, w,1, Color.new(0, 0, 0, 255))
   self.contents.font.color = normal_color
end

在 end 之前 插入如下语句
彩色部分是显示数字的坐标 自行调节
#显示角色hp值
self.contents.draw_text(x, y+20, 48, 32, actor.hp.to_s, 2)
#显示 斜杠
self.contents.draw_text(x+60, y+20, 12, 32, "/", 1)
#显示角色hp上限值
self.contents.draw_text(x+92, y+20, 48, 32, actor.maxhp.to_s) [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1