Project1

标题: 修改菜单的问题 [打印本页]

作者: invirgin    时间: 2015-12-12 11:49
标题: 修改菜单的问题
本帖最后由 invirgin 于 2015-12-12 22:10 编辑

各位大大 又来求助了
我在下了个菜单脚本,然后改了下。如图



但是出现了两个有选项的框,按键盘向右,两个一起向右。



我的理解是现在 有两个窗口是激活的,我想使最强装备那菜单 不激活,可是弄不了。

脚本如下

RUBY 代码复制
  1. class Scene_Map < Scene_Base
  2.   #--------------------------------------------------------------------------
  3.   # ● 打开菜单画面(修改为菜单直接进入物品界面)
  4.   #--------------------------------------------------------------------------
  5.   alias origin_call_menu call_menu
  6.   def call_menu
  7.     Sound.play_ok
  8.     SceneManager.call(Scene_Equip)
  9.     Window_MenuCommand::init_command_position
  10.   end
  11. end
  12.  
  13. #encoding:utf-8
  14. #==============================================================================
  15. # ■ Scene_Equip
  16. #------------------------------------------------------------------------------
  17. #  装备画面
  18. #==============================================================================
  19.  
  20. class Scene_Equip < Scene_MenuBase
  21.   #--------------------------------------------------------------------------
  22.   # ● 开始处理
  23.   #--------------------------------------------------------------------------
  24.   def initialize(last_scene = :scene_map)
  25.     super
  26.     @last_scene = last_scene
  27.   end
  28.   def start
  29.     super
  30.     create_help_window
  31.     create_status_window
  32.     create_command_window
  33.     create_slot_window
  34.     create_item_window
  35.     create_origin_command_window
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 生成状态窗口
  39.   #--------------------------------------------------------------------------
  40.   def create_status_window
  41.     @status_window = Window_EquipStatus.new(0, @help_window.height)
  42.     @status_window.viewport = @viewport
  43.     @status_window.actor = @actor
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 生成指令窗口
  47.   #--------------------------------------------------------------------------
  48.   def create_command_window
  49.     wx = @status_window.width
  50.     wy = @help_window.height
  51.     ww = Graphics.width - @status_window.width
  52.     @equip_command_window = Window_EquipCommand.new(wx, wy, ww)
  53.     @equip_command_window.viewport = @viewport
  54.     @equip_command_window.help_window = @help_window
  55.     @equip_command_window.set_handler(:equip,    method(:command_equip))
  56.     @equip_command_window.set_handler(:optimize, method(:command_optimize))
  57.     @equip_command_window.set_handler(:clear,    method(:command_clear))
  58.     @equip_command_window.set_handler(:cancel,   method(:return_scene))
  59.     @equip_command_window.set_handler(:pagedown, method(:next_actor))
  60.     @equip_command_window.set_handler(:pageup,   method(:prev_actor))
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 生成装备栏窗口
  64.   #--------------------------------------------------------------------------
  65.   def create_slot_window
  66.     wx = @status_window.width
  67. #~     wy = @help_window.y + @help_window.height
  68.     wy =@equip_command_window.y + @equip_command_window.height
  69.     ww = Graphics.width - @status_window.width
  70.     @slot_window = Window_EquipSlot.new(wx, wy, ww)
  71.     @slot_window.viewport = @viewport
  72.     @slot_window.help_window = @help_window
  73.     @slot_window.status_window = @status_window
  74.     @slot_window.actor = @actor
  75.     @slot_window.set_handler(:ok,       method(:on_slot_ok))
  76.     @slot_window.set_handler(:cancel,   method(:on_slot_cancel))
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 生成物品窗口
  80.   #--------------------------------------------------------------------------
  81.   def create_item_window
  82.     wx = 0
  83.     wy = @slot_window.y + @slot_window.height
  84.     ww = Graphics.width
  85.     wh = Graphics.height - wy
  86.     @item_window = Window_EquipItem.new(wx, wy, ww, wh)
  87.     @item_window.viewport = @viewport
  88.     @item_window.help_window = @help_window
  89.     @item_window.status_window = @status_window
  90.     @item_window.actor = @actor
  91.     @item_window.set_handler(:ok,     method(:on_item_ok))
  92.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  93.     @slot_window.item_window = @item_window
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● 指令“更换装备”
  97.   #--------------------------------------------------------------------------
  98.   def command_equip
  99.     @slot_window.activate
  100.     @slot_window.select(0)
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 指令“最强装备”
  104.   #--------------------------------------------------------------------------
  105.   def command_optimize
  106.     Sound.play_equip
  107.     @actor.optimize_equipments
  108.     @status_window.refresh
  109.     @slot_window.refresh
  110.     @equip_command_window.activate
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 指令“全部卸下”
  114.   #--------------------------------------------------------------------------
  115.   def command_clear
  116.     Sound.play_equip
  117.     @actor.clear_equipments
  118.     @status_window.refresh
  119.     @slot_window.refresh
  120.     @equip_command_window.activate
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 装备栏“确定”
  124.   #--------------------------------------------------------------------------
  125.   def on_slot_ok
  126.     @item_window.activate
  127.     @item_window.select(0)
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 装备栏“取消”
  131.   #--------------------------------------------------------------------------
  132.   def on_slot_cancel
  133.     @slot_window.unselect
  134.     @equip_command_window.activate
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 物品“确定”
  138.   #--------------------------------------------------------------------------
  139.   def on_item_ok
  140.     Sound.play_equip
  141.     @actor.change_equip(@slot_window.index, @item_window.item)
  142.     @slot_window.activate
  143.     @slot_window.refresh
  144.     @item_window.unselect
  145.     @item_window.refresh
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● 物品“取消”
  149.   #--------------------------------------------------------------------------
  150.   def on_item_cancel
  151.     @slot_window.activate
  152.     @item_window.unselect
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 切换角色
  156.   #--------------------------------------------------------------------------
  157.   def on_actor_change
  158.     @status_window.actor = @actor
  159.     @slot_window.actor = @actor
  160.     @item_window.actor = @actor
  161.     @equip_command_window.activate
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ● 生成指令窗口■
  165.   #--------------------------------------------------------------------------
  166.   def create_origin_command_window
  167.     @command_window = Window_MenuCommand.new
  168.     @command_window.set_handler(:item,      method(:command_item))
  169.     @command_window.set_handler(:skill,     method(:command_skill))
  170.     @command_window.set_handler(:equip,     method(:command_equip))
  171.     @command_window.set_handler(:cancel,    method(:return_scene))
  172.     @command_window.select(0)
  173.     @command_window.active = @last_scene == :scene_map
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● 指令“物品”■
  177.   #--------------------------------------------------------------------------
  178.   def command_item
  179.     SceneManager.call(Scene_Item)#, :Scene_Equip)
  180.     @item_window.activate
  181.     @item_window.select(0)
  182.   end
  183.  
  184.   #--------------------------------------------------------------------------
  185.   # ● 指令“技能”■
  186.   #--------------------------------------------------------------------------
  187.   def command_skill
  188.     SceneManager.call_new(Scene_Skill, :Scene_Equip)
  189.   end
  190. end




作者: 喵呜喵5    时间: 2015-12-12 21:38
先不提两个光标都有效的问题

楼主你没发现你定义了两个 command_equip 方法吗?
作者: invirgin    时间: 2015-12-12 23:06


我本以为是此处的 @slot_window.activate 使窗口有效。但注释后无改变

是不是 导致 “最强装备”光标窗口有效的命令 不在我给出的脚本之内?
作者: cinderelmini    时间: 2015-12-12 23:10
LZ似乎已经注意到了同名变量,但是还要注意指令类窗口的同名指令的问题,还有就是各种窗口之间的激活和反激活操作。
大概这样:

作者: invirgin    时间: 2015-12-13 09:24



感谢椎名大 我粘了你的脚本  只是还是 两个光标框呢






呵呵 椎名大可能已经看出来了 这就是您上次 给我写的菜单脚本 我正仿照 着自己改 可是只改了一点就出问题了,记得当时得到大大的脚本,好的问题豁然开亮,但随着深入又有了新问题,呵呵 都一个月了,我还没弄明白。{:2_271:}




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