| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 14 |  
| 积分 | 1 |  
| 经验 | 11195 |  
| 最后登录 | 2017-6-7 |  
| 在线时间 | 543 小时 |  
 Lv1.梦旅人 
	梦石0 星屑50 在线时间543 小时注册时间2009-7-13帖子63 | 
| 本帖最后由 nanaka 于 2011-9-8 13:10 编辑 
 需要加图标的时候用这个类生成实例,第三个参数是图标的序号的数组复制代码class Window_Command_With_Icon < Window_Selectable
  attr_reader   :commands                 
  
  def initialize(width, commands, icon_list, column_max = 1, row_max = 0, spacing = 32)
    if row_max == 0
      row_max = (commands.size + column_max - 1) / column_max
    end
    super(0, 0, width, row_max * WLH + 32, spacing)
    @commands = commands
    @item_max = commands.size
    @column_max = column_max
    self.index = 0
    @icon_list = icon_list
    refresh
  end
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  def draw_item(index, enabled = true)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    icon_index = @icon_list[index]
    if  index != nil and icon_index != 0
      rect.x -= 4
      draw_icon(icon_index, rect.x, rect.y, enabled)
      rect.x += 26
      rect.width -= 20
    end
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index])
  end
end
比如@command_window = Window_Command_With_Icon.new(172, [s1, s2, s3], [3,5,7])
 
 点评写不下了……
 Scene_Menu60行左右改成
 @command_window = Window_Command_With_Icon.new(160, [s1, s2, s3, s4, s5, s6],[这里填你想加的图标序号])
 
 | 
 |