设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1553|回复: 1
打印 上一主题 下一主题

自制的ARPG人物窗口无法监控状态变化的问题

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
7 小时
注册时间
2007-7-15
帖子
28
跳转到指定楼层
1
发表于 2007-7-31 05:18:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
以下脚本是我根据主站上的范例修改而来的,

  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变化时可以在窗口中反映出来,而状态变化时却无法在窗口中反映出来。看了半天,愣是没看出来是为什么,只能上论坛求助了。还请各位高手帮帮忙,不胜感激。

Lv1.梦旅人

梦石
0
星屑
50
在线时间
7 小时
注册时间
2007-7-15
帖子
28
2
 楼主| 发表于 2007-7-31 05:18:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
以下脚本是我根据主站上的范例修改而来的,

  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变化时可以在窗口中反映出来,而状态变化时却无法在窗口中反映出来。看了半天,愣是没看出来是为什么,只能上论坛求助了。还请各位高手帮帮忙,不胜感激。
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2026-7-1 19:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表