Project1

标题: 自制的ARPG人物窗口无法监控状态变化的问题 [打印本页]

作者: 未知的赞歌    时间: 2007-7-31 05:18
标题: 自制的ARPG人物窗口无法监控状态变化的问题
以下脚本是我根据主站上的范例修改而来的,

  1. #===============================================================================
  2. # ■ Window_MapStatus
  3. #-------------------------------------------------------------------------------
  4. # 在地图上显示的状态窗口
  5. #===============================================================================

  6. class Window_MapStatus < Window_Base
  7.   attr_accessor :actor                  # 当前角色
  8.   #-----------------------------------------------------------------------------
  9.   # ● 初始化
  10.   #-----------------------------------------------------------------------------
  11.   def initialize
  12.     super(0,0,160,100)
  13.     self.contents=Bitmap.new(width,height)
  14.     self.back_opacity=0
  15.     self.contents.font.size=14
  16.     self.visible = false
  17.     self.windowskin=nil
  18.     unless $game_party.actors.size<1
  19.       @actor=$game_party.actors[0]
  20.       
  21.       @last_actor=@actor
  22.       @[email protected]
  23.       @[email protected]
  24.       @[email protected]
  25.       @[email protected]
  26.       @[email protected]
  27.       @[email protected]_s
  28.       @[email protected]
  29.       @last_vis=self.visible
  30.       
  31.       self.visible = true
  32.       refresh
  33.     end
  34.   end
  35.   #-----------------------------------------------------------------------------
  36.   # ● 刷新画面
  37.   #-----------------------------------------------------------------------------
  38.   def refresh
  39.     self.contents.clear
  40.     draw_actor_graphic2(actor)
  41.     draw_actor_name(actor, 40, -10)
  42.     draw_actor_hp(actor, 40, 4, 88)
  43.     draw_actor_sp(actor, 40, 18, 88)
  44.     draw_actor_exp(actor,40,30,88)
  45.     draw_actor_state(actor, 40, 46)

  46.   end
  47.   #-----------------------------------------------------------------------------
  48.   # ● 更新
  49.   #-----------------------------------------------------------------------------
  50.   def update
  51.     super
  52.     if self.changed?
  53.       refresh
  54.     end
  55.   end
  56.   #----------------------------------------------------------------------------
  57.   # ● 改变标志
  58.   #----------------------------------------------------------------------------
  59.   def changed?
  60.     c = false
  61.     if (@actor != @last_actor or @actor.hp != @last_hp or @actor.sp != @last_sp or
  62.       @actor.maxhp != @last_maxhp or @actor.maxsp != @last_maxsp or (@last_vis != true and self.visible ==true) or
  63.       @actor.level != @last_level or @actor.exp_s != @last_exp_s or @actor.states != @last_states)
  64.       c = true
  65.       @last_actor=@actor
  66.       @[email protected]
  67.       @[email protected]
  68.       @[email protected]
  69.       @[email protected]
  70.       @[email protected]
  71.       @[email protected]_s
  72.       @[email protected]
  73.       @last_vis=self.visible
  74.     end
  75.     return c
  76.   end
  77.   #----------------------------------------------------------------------------
  78.   # ● 专用绘图
  79.   #----------------------------------------------------------------------------
  80.   def draw_actor_graphic2(actor)
  81.    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  82.    cw = bitmap.width / $c3_每一步的帧数
  83.    ch = bitmap.height / $c3_总共可用的方向数
  84.    src_rect = Rect.new(0, 0, cw, ch)
  85.    dest_rect = Rect.new(-8, 0, 42, 74)
  86.    self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  87.   end
  88. end
复制代码

但使用时,却出现了让人郁闷的问题:当hp或sp变化时可以在窗口中反映出来,而状态变化时却无法在窗口中反映出来。看了半天,愣是没看出来是为什么,只能上论坛求助了。还请各位高手帮帮忙,不胜感激。
作者: 未知的赞歌    时间: 2007-7-31 05:18
标题: 自制的ARPG人物窗口无法监控状态变化的问题
以下脚本是我根据主站上的范例修改而来的,

  1. #===============================================================================
  2. # ■ Window_MapStatus
  3. #-------------------------------------------------------------------------------
  4. # 在地图上显示的状态窗口
  5. #===============================================================================

  6. class Window_MapStatus < Window_Base
  7.   attr_accessor :actor                  # 当前角色
  8.   #-----------------------------------------------------------------------------
  9.   # ● 初始化
  10.   #-----------------------------------------------------------------------------
  11.   def initialize
  12.     super(0,0,160,100)
  13.     self.contents=Bitmap.new(width,height)
  14.     self.back_opacity=0
  15.     self.contents.font.size=14
  16.     self.visible = false
  17.     self.windowskin=nil
  18.     unless $game_party.actors.size<1
  19.       @actor=$game_party.actors[0]
  20.       
  21.       @last_actor=@actor
  22.       @[email protected]
  23.       @[email protected]
  24.       @[email protected]
  25.       @[email protected]
  26.       @[email protected]
  27.       @[email protected]_s
  28.       @[email protected]
  29.       @last_vis=self.visible
  30.       
  31.       self.visible = true
  32.       refresh
  33.     end
  34.   end
  35.   #-----------------------------------------------------------------------------
  36.   # ● 刷新画面
  37.   #-----------------------------------------------------------------------------
  38.   def refresh
  39.     self.contents.clear
  40.     draw_actor_graphic2(actor)
  41.     draw_actor_name(actor, 40, -10)
  42.     draw_actor_hp(actor, 40, 4, 88)
  43.     draw_actor_sp(actor, 40, 18, 88)
  44.     draw_actor_exp(actor,40,30,88)
  45.     draw_actor_state(actor, 40, 46)

  46.   end
  47.   #-----------------------------------------------------------------------------
  48.   # ● 更新
  49.   #-----------------------------------------------------------------------------
  50.   def update
  51.     super
  52.     if self.changed?
  53.       refresh
  54.     end
  55.   end
  56.   #----------------------------------------------------------------------------
  57.   # ● 改变标志
  58.   #----------------------------------------------------------------------------
  59.   def changed?
  60.     c = false
  61.     if (@actor != @last_actor or @actor.hp != @last_hp or @actor.sp != @last_sp or
  62.       @actor.maxhp != @last_maxhp or @actor.maxsp != @last_maxsp or (@last_vis != true and self.visible ==true) or
  63.       @actor.level != @last_level or @actor.exp_s != @last_exp_s or @actor.states != @last_states)
  64.       c = true
  65.       @last_actor=@actor
  66.       @[email protected]
  67.       @[email protected]
  68.       @[email protected]
  69.       @[email protected]
  70.       @[email protected]
  71.       @[email protected]_s
  72.       @[email protected]
  73.       @last_vis=self.visible
  74.     end
  75.     return c
  76.   end
  77.   #----------------------------------------------------------------------------
  78.   # ● 专用绘图
  79.   #----------------------------------------------------------------------------
  80.   def draw_actor_graphic2(actor)
  81.    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  82.    cw = bitmap.width / $c3_每一步的帧数
  83.    ch = bitmap.height / $c3_总共可用的方向数
  84.    src_rect = Rect.new(0, 0, cw, ch)
  85.    dest_rect = Rect.new(-8, 0, 42, 74)
  86.    self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  87.   end
  88. end
复制代码

但使用时,却出现了让人郁闷的问题:当hp或sp变化时可以在窗口中反映出来,而状态变化时却无法在窗口中反映出来。看了半天,愣是没看出来是为什么,只能上论坛求助了。还请各位高手帮帮忙,不胜感激。




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