| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 0 |  
| 积分 | 1 |  
| 经验 | 495 |  
| 最后登录 | 2014-2-15 |  
| 在线时间 | 9 小时 |  
 Lv1.梦旅人 
	梦石0 星屑50 在线时间9 小时注册时间2014-2-6帖子11 | 
6楼
 
 
 楼主|
发表于 2014-2-7 22:35:21
|
只看该作者 
| 那部分脚本是这样的 是我的问题提得不好。我想知道是什么方法调用了draw_item(index),带入index的参数是什么,在哪里。index貌似是项目编号确定矩形位置用的但我不太懂他的工作原理,求解释。复制代码class Window_NewMenuStatus < Window_Command
  #----------------------------------------------------------------------------
  # * 初始化
  #----------------------------------------------------------------------------
  def initialize
    super(160, 0)
  end
  #----------------------------------------------------------------------------
  # * 获取窗口的宽度
  #----------------------------------------------------------------------------
  def window_width
    return 384
  end
  #----------------------------------------------------------------------------
  # * 获取窗口的高度
  #----------------------------------------------------------------------------
  def window_height
    return 416
  end
  #----------------------------------------------------------------------------
  # * 更新窗口
  #----------------------------------------------------------------------------
  def update
    super
  end
  #----------------------------------------------------------------------------
  # * 生成指令列表
  #----------------------------------------------------------------------------
  def make_command_list
    for actor in $game_party.members
      s = "a[#{actor.id}]"
      add_command(actor.name,s.to_sym,!actor.death_state?,actor.id)
    end
  end
  #-----------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect_for_text(index)
    cn = $game_actors[@list[index][    b = Bitmap.new(rect.width,rect.height)
:ext]].character_name
    ci = $game_actors[@list[index][:ext]].character_index
    cb = Cache.character(cn)
    #---------------------------------------------------------------------------
    #     *提取$或无$开头的点阵图2号位的图像
    #---------------------------------------------------------------------------
    sign = cn[/^[\!\$]./]
    if sign && sign.include?('是我的问题提得不好。我想知道是什么方法调用了draw_item(index),带入index的参数是什么,在哪里。index貌似是项目编号确定矩形位置用的但我不太懂他的工作原理,求解释。)
      cr = Rect.new
      cr.x = cb.width / 3
      cr.width = cb.width / 3
      cr.height = cb.height / 4
    else
      cr = Rect.new
      cr.x = ci % 4 * (cb.width / 4) + cb.width / 12
      cr.y = ci / 4 * (cb.height / 2)
      cr.width = cb.width / 12
      cr.height = cb.height / 8
    end
    #---------------------------------------------------------------------------
    #    *居中描绘点阵图
    #---------------------------------------------------------------------------
    #b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr)
    self.contents.blt(rect.x * (b.width - cr.width) / 2, rect.y, cb, cr)
  end
  #-----------------------------------------------------------------------------
  #    *定义选择框为方形(菜单宽度/4 * 48)
  #-----------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = self.contents.width / 4
    rect.height = 48
    rect.x = index < 4 ? index * rect.width : (index - 4) * rect.width
    rect.y = index < 4 ? 0 : self.contents.height - rect.height
    return rect
  end
end
 | 
 |