Project1

标题: 如何让下面的脚本变成窗口? [打印本页]

作者: 876加几    时间: 2013-10-20 19:00
标题: 如何让下面的脚本变成窗口?
我打印了一下,本身应该是Window的脚本结果不是true,而是false。
  1. #==============================================================================
  2. # ■ Window_ActorMessage
  3. #------------------------------------------------------------------------------
  4. #  显示角色血糟的窗口。
  5. #==============================================================================

  6. class Window_ActorMessage < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化窗口
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 480 - 64, 640, 64)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     self.opacity = 0
  14.     refresh
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 刷新
  18.   #--------------------------------------------------------------------------
  19.   def refresh
  20.     self.contents.clear
  21.     for i in 0...$game_party.actors.size
  22.       x = 160 * i
  23.       y = 0
  24.       actor = $game_party.actors[i]
  25.       draw_actor_head(actor, x, y)
  26.       carol3_draw_hp_bar(actor, x + 64, y + 1)
  27.       carol3_draw_sp_bar(actor, x + 64, y + 16)
  28.       carol3_draw_cp_bar(actor, x + 64, y + 32)
  29.     end
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 刷新画面
  33.   #--------------------------------------------------------------------------
  34.   def update
  35.     super
  36.     refresh
  37.   end
  38. end
复制代码
方法:
  1.   #--------------------------------------------------------------------------
  2.   # ● 头像的描绘
  3.   #     actor : 角色
  4.   #     x     : 描画目标 X 坐标
  5.   #     y     : 描画目标 Y 坐标
  6.   #--------------------------------------------------------------------------
  7.   def draw_actor_head(actor, x, y)
  8.     bitmap = RPG::Cache.picture(actor.character_name + "_h")
  9.     hea_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  10.     self.contents.blt(x, y, bitmap, hea_rect)
  11.   end
  12.   #---------------------------------------------------------------------------
  13.   # 定义新方法名,就相当于Window_Base的draw_actor_hp
  14.   # 带有四个参数,角色,你给谁描绘血条呢?给这个角色
  15.   # 参数描绘,相对的X,Y坐标,以及血条的宽度
  16.   # 方法名完全可以改为draw_actor_hp,在window中用
  17.   #---------------------------------------------------------------------------
  18.   def carol3_draw_hp_bar(actor, x, y, width = 78)
  19.     # 自身文字颜色为系统文字色
  20.     self.contents.fill_rect(x-1, y-1, width + 2,10, Color.new(0, 0, 0, 255))
  21.     # 计算红条宽度,很简单。宽度 = 角色当前HP / 最大HP × 宽度
  22.     w = width * actor.hp / actor.maxhp
  23.     # 填充矩形,要不颜色太单调,也不好看,下面四行不是重点
  24.     self.contents.fill_rect(x, y, w,8, Color.new(255, 0, 0, 255))
  25.   end
  26.   # 下方的基本一样,就不多废话了,只说不一样的地方。
  27.   def carol3_draw_sp_bar(actor, x, y, width = 78)
  28.     self.contents.fill_rect(x-1, y-1, width + 2,10, Color.new(0, 0, 0, 255))
  29.     w = width * actor.sp / actor.maxsp
  30.     #下方就不多说了。
  31.     self.contents.fill_rect(x, y, w,8, Color.new(0, 0, 255, 255))
  32.   end
  33.   def carol3_draw_cp_bar(actor, x, y, width = 58)
  34.     if actor.mor == 100
  35.       self.contents.fill_rect(x-2, y-2, width + 4,7, Color.new(0, 255, 0, 170))
  36.     end
  37.     self.contents.fill_rect(x-1, y-1, width + 2,5, Color.new(0, 0, 0, 255))
  38.     w = width * actor.mor / 100
  39.     self.contents.fill_rect(x, y, w,3, Color.new(0, 255, 0, 255))
  40.   end
复制代码
打印方法:
  1. @squarebattleactormessage_window = Window_ActorMessage.new
  2. p @squarebattleactormessage_window.is_a?(Window)
复制代码
应该为true,结果为false,这是怎么回事?
作者: 英顺的马甲    时间: 2013-10-20 21:13
无此问题,一切正常




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