Project1

标题: 装备item界面的。。。修改。。 [打印本页]

作者: 黄濑凉太    时间: 2015-5-27 17:50
标题: 装备item界面的。。。修改。。
不知道被我改了什么……
变成了这样:

得到了4个武器,但是只显示两列,并且无法查看其他的装备,
当装备了一个装备后…………

就替换成了其他的。。。
怎么把item栏增加到4个 并且可以向下拉? 之类的
要修改哪里呢……一些可能相关的脚本:
RUBY 代码复制
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Scene_Equip
  4. #------------------------------------------------------------------------------
  5. #  装备画面
  6. #==============================================================================
  7.  
  8. class Scene_Equip < Scene_MenuBase
  9.   #--------------------------------------------------------------------------
  10.   # ● 开始处理
  11.   #--------------------------------------------------------------------------
  12.   def start
  13.     super
  14.     create_help_window
  15.     @help_window.x = 544
  16.     create_status_window
  17.     create_slot_window
  18.     create_item_window
  19.   end
  20.       def create_background
  21.     @background_sprite = Sprite.new
  22.     @background_sprite.bitmap = Cache.title1("Menu_equip")
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 生成状态窗口
  26.   #--------------------------------------------------------------------------
  27.   def create_status_window
  28.     @status_window = Window_EquipStatus.new(0, 0)
  29.     @status_window.viewport = @viewport
  30.     @status_window.actor = @actor
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● 生成装备栏窗口
  34.   #--------------------------------------------------------------------------
  35.   def create_slot_window
  36.     wx = @status_window.width + 70
  37.     wy = 0
  38.     ww = Graphics.width - @status_window.width - 90
  39.     @slot_window = Window_EquipSlot.new(wx, wy, ww)
  40.     @slot_window.viewport = @viewport
  41.     @slot_window.help_window = @help_window
  42.     @slot_window.status_window = @status_window
  43.     @slot_window.actor = @actor
  44.     @slot_window.set_handler(:ok,       method(:on_slot_ok))
  45.     @slot_window.set_handler(:cancel,   method(:return_scene))
  46.     command_equip
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # ● 生成物品窗口
  50.   #--------------------------------------------------------------------------
  51.   def create_item_window
  52.     wx = @status_window.width + 70
  53.     wy = @slot_window.y + @slot_window.height - 40
  54.     ww = Graphics.width  - 35
  55.     wh = Graphics.height + 60
  56.     @item_window = Window_EquipItem.new(wx, wy, ww, wh)
  57.     @item_window.viewport = @viewport
  58.     @item_window.help_window = @help_window
  59.     @item_window.status_window = @status_window
  60.     @item_window.actor = @actor
  61.     @item_window.set_handler(:ok,     method(:on_item_ok))
  62.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  63.     @slot_window.item_window = @item_window
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 指令“更换装备”
  67.   #--------------------------------------------------------------------------
  68.   def command_equip
  69.     @slot_window.activate
  70.     @slot_window.select(0)
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 装备栏“确定”
  74.   #--------------------------------------------------------------------------
  75.   def on_slot_ok
  76.     @item_window.activate
  77.     @item_window.select(0)
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 物品“确定”
  81.   #--------------------------------------------------------------------------
  82.   def on_item_ok
  83.     Sound.play_equip
  84.     @actor.change_equip(@slot_window.index, @item_window.item)
  85.     @slot_window.activate
  86.     @slot_window.refresh
  87.     @item_window.unselect
  88.     @item_window.refresh
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● 物品“取消”
  92.   #--------------------------------------------------------------------------
  93.   def on_item_cancel
  94.     @slot_window.activate
  95.     @item_window.unselect
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 切换角色
  99.   #--------------------------------------------------------------------------
  100.   def on_actor_change
  101.     @status_window.actor = @actor
  102.     @slot_window.actor = @actor
  103.     @item_window.actor = @actor
  104.     @slot_window.activate
  105.   end
  106. end

RUBY 代码复制
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Window_EquipItem
  4. #------------------------------------------------------------------------------
  5. #  装备画面中,显示可替换装备的窗口。
  6. #==============================================================================
  7.  
  8. class Window_EquipItem < Window_ItemList
  9.   #--------------------------------------------------------------------------
  10.   # ● 定义实例变量
  11.   #--------------------------------------------------------------------------
  12.   attr_reader   :status_window            # 状态窗口
  13.   #--------------------------------------------------------------------------
  14.   # ● 初始化对象
  15.   #--------------------------------------------------------------------------
  16.   def initialize(x, y, width, height)
  17.     super
  18.     self.opacity = 0
  19.     @actor = nil
  20.     @slot_id = 0
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 设置角色
  24.   #--------------------------------------------------------------------------
  25.   def actor=(actor)
  26.     return if @actor == actor
  27.     @actor = actor
  28.     refresh
  29.     self.oy = 0
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 设置装备栏 ID
  33.   #--------------------------------------------------------------------------
  34.   def slot_id=(slot_id)
  35.     return if @slot_id == slot_id
  36.     @slot_id = slot_id
  37.     refresh
  38.     self.oy = 0
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 查询使用列表中是否含有此物品
  42.   #--------------------------------------------------------------------------
  43.   def include?(item)
  44.     return true if item == nil
  45.     return false unless item.is_a?(RPG::EquipItem)
  46.     return false if @slot_id < 0
  47.     return false if item.etype_id != @actor.equip_slots[@slot_id]
  48.     return @actor.equippable?(item)
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 查询此文件是否可以装备
  52.   #--------------------------------------------------------------------------
  53.   def enable?(item)
  54.     return true
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● 返回上一个选择的位置
  58.   #--------------------------------------------------------------------------
  59.   def select_last
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 设置状态窗口
  63.   #--------------------------------------------------------------------------
  64.   def status_window=(status_window)
  65.     @status_window = status_window
  66.     call_update_help
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 更新帮助内容
  70.   #--------------------------------------------------------------------------
  71.   def update_help
  72.     super
  73.     if @actor && @status_window
  74.       temp_actor = Marshal.load(Marshal.dump(@actor))
  75.       temp_actor.force_change_equip(@slot_id, item)
  76.       @status_window.set_temp_actor(temp_actor)
  77.     end
  78.   end
  79. end


作者: cinderelmini    时间: 2015-5-28 12:09
Window_EquipItem 似乎默认的col_max(列数)(从父类继承的?)是2,
试试在这里面加一行:
  1. def col_max; return 1; end
复制代码





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