Project1

标题: 关于Window_Status中的参数actor [打印本页]

作者: kklt    时间: 2016-7-20 15:22
标题: 关于Window_Status中的参数actor
RUBY 代码复制
  1. #------------------------------------------------------------------------------
  2. #  状态画面中,显示角色基本信息的窗口。
  3. #==============================================================================
  4.  
  5. class Window_Status < Window_Selectable
  6.   #--------------------------------------------------------------------------
  7.   # ● 初始化对象
  8.   #--------------------------------------------------------------------------
  9.   def initialize(actor)
  10.     super(0, 0, Graphics.width, Graphics.height)
  11.     @actor = actor
  12.     refresh
  13.     self.opacity = 0
  14.     activate
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 获取窗口的宽度
  18.   #--------------------------------------------------------------------------
  19.   def window_width
  20.     Graphics.width - 160
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 获取窗口的高度
  24.   #--------------------------------------------------------------------------
  25.   def window_height
  26.     Graphics.height
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 设置角色
  30.   #--------------------------------------------------------------------------
  31.   def actor=(actor)
  32.     return if @actor == actor
  33.     @actor = actor
  34.     refresh
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 刷新
  38.   #--------------------------------------------------------------------------
  39.   def refresh
  40.     contents.clear
  41.     draw_block1   (line_height * 0)
  42.     draw_horz_line(line_height * 1)
  43.     draw_block2   (line_height * 2)
  44.     draw_horz_line(line_height * 6)
  45.     draw_block3   (line_height * 7)
  46.     draw_horz_line(line_height * 13)
  47.     draw_block4   (line_height * 14)
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 绘制区域 1
  51.   #--------------------------------------------------------------------------
  52.   #def draw_block1(y)
  53.   #  draw_actor_name(@actor, 4, y)
  54.   #  draw_actor_class(@actor, 128, y)
  55.   #  draw_actor_nickname(@actor, 288, y)
  56.   #end
  57.   #--------------------------------------------------------------------------
  58.   # ● 绘制区域 2
  59.   #--------------------------------------------------------------------------
  60.   def draw_block2(y)
  61.     #draw_actor_face(@actor, 8, y)
  62.     draw_basic_info(255, y)
  63.     #draw_exp_info(304, y)
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 绘制区域 3
  67.   #--------------------------------------------------------------------------
  68.   def draw_block3(y)
  69.     draw_parameters(255, y)
  70.     draw_equipments(300, y)
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 绘制区域 4
  74.   #--------------------------------------------------------------------------
  75. # def draw_block4(y)
  76.   #  draw_description(4, y)
  77. # end
  78.   #--------------------------------------------------------------------------
  79.   # ● 绘制水平线
  80.   #--------------------------------------------------------------------------
  81.   #def draw_horz_line(y)
  82.   #  line_y = y + line_height / 2 - 1
  83.   #  contents.fill_rect(0, line_y, contents_width, 2, line_color)
  84. # end
  85.   #--------------------------------------------------------------------------
  86.   # ● 获取水平线的颜色
  87.   #--------------------------------------------------------------------------
  88.   #def line_color
  89.   #  color = normal_color
  90.   #  color.alpha = 48
  91.   #  color
  92.   #end
  93.   #--------------------------------------------------------------------------
  94.   # ● 绘制基本信息
  95.   #--------------------------------------------------------------------------
  96.   def draw_basic_info(x, y)
  97.     draw_actor_level(@actor, x, y + line_height * 0)
  98.     draw_actor_icons(@actor, x, y + line_height * 1)
  99.     draw_actor_hp(@actor, x, y + line_height * 2)
  100.     draw_actor_mp(@actor, x, y + line_height * 3)
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 绘制能力值
  104.   #--------------------------------------------------------------------------
  105.   def draw_parameters(x, y)
  106.     6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  107.   end
  108. =begin  
  109.   #--------------------------------------------------------------------------
  110.   # ● 绘制经验值信息
  111.   #--------------------------------------------------------------------------
  112.   def draw_exp_info(x, y)
  113.     s1 = @actor.max_level? ? "-------" : @actor.exp
  114.     s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
  115.     s_next = sprintf(Vocab::ExpNext, Vocab::level)
  116.     change_color(system_color)
  117.     draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
  118.     draw_text(x, y + line_height * 2, 180, line_height, s_next)
  119.     change_color(normal_color)
  120.     draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
  121.     draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
  122.   end
  123. =end  
  124.   #--------------------------------------------------------------------------
  125.   # ● 绘制装备
  126.   #--------------------------------------------------------------------------
  127.   def draw_equipments(x, y)
  128.     @actor.equips.each_with_index do |item, i|
  129.       draw_item_name(item, x, y + line_height * i)
  130.     end
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● 绘制说明
  134.   #--------------------------------------------------------------------------
  135. # def draw_description(x, y)
  136. #   draw_text_ex(x, y, @actor.description)
  137. # end
  138. end

第八行的参数actor是要传递什么?角色的index?还是角色名?
作者: il4j    时间: 2016-7-20 15:47
角色的对象,这个对象有ID、姓名等属性




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