Project1

标题: 新手刚学脚本,求测试求修改求指导 [打印本页]

作者: taroxd    时间: 2013-10-19 20:07
标题: 新手刚学脚本,求测试求修改求指导
本帖最后由 taroxd 于 2013-11-9 19:05 编辑

新手几乎没有编程基础,只会瞎改改。RGSS3的书写规范也不是很清楚。如果看到有问题,希望能不吝赐教!

1.修改自这里的脚本,使得只显示HP条,且地图上HP发生变化时可以及时更新。问一下,这样判断是否合理?
RUBY 代码复制
  1. #============================================================================
  2. #  〇 地图显示血条
  3. #============================================================================
  4. class Scene_Map < Scene_Base
  5.   #--------------------------------------------------------------------------
  6.   # ● 开始处理
  7.   #--------------------------------------------------------------------------
  8.   alias hp_window_start start
  9.   def start
  10.     hp_window_start
  11.     @hp_window = Window_hp.new
  12.     @hp_window.refresh
  13.     @hp_window.hide
  14.   end
  15.   alias hp_window_update update
  16.   def update
  17.     hp_window_update
  18.     @hp_window.refresh if @hp_window.need_refresh?
  19.     @hp_window.visible = true
  20. #~     @hp_window.visible = $game_switches[1] #控制开关
  21.   end
  22. end
  23.  
  24. class Window_hp < Window_Base
  25.   #--------------------------------------------------------------------------
  26.   # ● 初始化对象
  27.   #--------------------------------------------------------------------------
  28.   def initialize
  29.     @party_hp_rate = []
  30.     super(-12, -16, 544 + 12, 416 + 16)
  31.     self.opacity = 0
  32.     update
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 绘制 HP
  36.   #--------------------------------------------------------------------------
  37.   def notext_draw_actor_hp(actor, x, y, width = 124)
  38.     draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  39.     change_color(system_color)
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ● 绘制全队 HP
  43.   #--------------------------------------------------------------------------
  44.   def notext_draw_party_hp
  45.     $game_party.all_members.each_with_index do |actor, i|
  46.       notext_draw_actor_hp(actor, 0, 16 * i)
  47.     end
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 获取全队 HP 的比率
  51.   #--------------------------------------------------------------------------
  52.   def party_hp_rate
  53.     $game_party.all_members.collect {|actor| actor.hp_rate}
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 刷新
  57.   #--------------------------------------------------------------------------
  58.   def refresh
  59.     contents.clear
  60.     notext_draw_party_hp
  61.     @party_hp_rate = party_hp_rate
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● 判定是否需要刷新
  65.   #--------------------------------------------------------------------------
  66.   def need_refresh?
  67.     !(party_hp_rate == @party_hp_rate)
  68.   end
  69. end





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