#-------------------------------------------------------------------------- # ● 增设能力值 #-------------------------------------------------------------------------- class Scene_Menu < Scene_MenuBase #-------------------------------------------------------------------------- # ● 生成指令窗口(增设「七」窗口) #-------------------------------------------------------------------------- def create_command_window @command_window = Window_MenuCommand.new @command_window.set_handler(:item, method(:command_item)) @command_window.set_handler(:skill, method(:command_skill)) @command_window.set_handler(:equip, method(:command_equip)) @command_window.set_handler(:scommand, method(:command_scommand)) @command_window.set_handler(:save, method(:command_save)) @command_window.set_handler(:game_end, method(:command_game_end)) @command_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # ● 生成状态窗口 #-------------------------------------------------------------------------- def create_status_window @status_window = Window_Status.new(@actor) end #-------------------------------------------------------------------------- # ● 指令“七” #-------------------------------------------------------------------------- def command_scommand SceneManager.call(Scene_scommand) end def command_skill SceneManager.call(Scene_Skill) end def command_equip SceneManager.call(Scene_Equip) end end class Window_MenuCommand < Window_Command #-------------------------------------------------------------------------- # ● 向指令列表添加主要的指令(增设「七」指令) #-------------------------------------------------------------------------- def add_original_commands add_command("七", :scommand, main_commands_enabled) end end #-------------------------------------------------------------------------- # ● 增设统计 #-------------------------------------------------------------------------- class Scene_scommand < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super create_scommand_window end #-------------------------------------------------------------------------- # ● 生成指令窗口 #-------------------------------------------------------------------------- def create_scommand_window @scommand_window = Window_SuCommand.new @scommand_window.set_handler(:aaa, method(:command_aaa)) @scommand_window.set_handler(:bbb, method(:command_bbb)) @scommand_window.set_handler(:ccc, method(:command_ccc)) @scommand_window.set_handler(:ddd, method(:command_ddd)) @scommand_window.set_handler(:eee, method(:command_eee)) @scommand_window.set_handler(:fff, method(:command_fff)) @scommand_window.set_handler(:cancel, method(:return_scene)) end def command_aaa SceneManager.call(Scene_aaa_window) end def command_bbb SceneManager.call(Scene_bbb_window) end def command_ccc SceneManager.call(Scene_ccc_window) end def command_ddd SceneManager.call(Scene_ddd_window) end def command_eee SceneManager.call(Scene_eee_window) end def command_fff SceneManager.call(Scene_fff_window) end end class Window_SuCommand < Window_HorzCommand #-------------------------------------------------------------------------- # ● 初始化指令选择位置(类方法) #-------------------------------------------------------------------------- def self.init_command_position @@last_command_symbol = nil end #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize super(0, 0) select_last end #-------------------------------------------------------------------------- # ● 获取窗口的宽度 #-------------------------------------------------------------------------- def window_width return 544 end #-------------------------------------------------------------------------- # ● 获取窗口的高度 #-------------------------------------------------------------------------- def window_height return 48 end #-------------------------------------------------------------------------- # ● 获取列数 #-------------------------------------------------------------------------- def col_max return 6 end #-------------------------------------------------------------------------- # ● 生成指令列表 #-------------------------------------------------------------------------- def make_command_list add_main_commands end #-------------------------------------------------------------------------- # ● 向指令列表添加主要的指令 #-------------------------------------------------------------------------- def add_main_commands add_command("一", :aaa,) add_command("二", :bbb,) add_command("三", :ccc,) add_command("四", :ddd,) add_command("五", :eee,) add_command("六", :fff,) end #-------------------------------------------------------------------------- # ● 按下确定键时的处理 #-------------------------------------------------------------------------- def process_ok @@last_command_symbol = current_symbol super end #-------------------------------------------------------------------------- # ● 返回最后一个选项的位置 #-------------------------------------------------------------------------- def select_last end end class Scene_aaa_window < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super @aaa_window = Window_aaa.new(@actor) @aaa_window.set_handler(:cancel, method(:return_scene)) end end class Scene_bbb_window < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super @bbb_window = Window_bbb.new(@actor) @bbb_window.set_handler(:cancel, method(:return_scene)) end end class Scene_ccc_window < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super @ccc_window = Window_ccc.new(@actor) @ccc_window.set_handler(:cancel, method(:return_scene)) end end class Scene_ddd_window < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super @ddd_window = Window_ddd.new(@actor) @ddd_window.set_handler(:cancel, method(:return_scene)) end end class Scene_eee_window < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super @eee_window = Window_eee.new(@actor) @eee_window.set_handler(:cancel, method(:return_scene)) end end class Scene_fff_window < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super @fff_window = Window_fff.new(@actor) @fff_window.set_handler(:cancel, method(:return_scene)) end end
#-------------------------------------------------------------------------- # ● 返回最后一个选项的位置 #-------------------------------------------------------------------------- def select_last select_symbol(@@last_command_symbol) end
class Scene_scommand < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super create_scommand_window create_se_window end def create_se_window @se_window = Window_aaa.new(@actor) end end
chd114 发表于 2018-3-4 10:28
Window_选项窗口中添加选项的指令
add_command("选项名称", :选项对应的键, 判断选项是否有 ...
真紅樂章 发表于 2018-3-4 12:42
添加的选项也有效的说
按键进入後触发的画面也合符预期喔
问题是按键退出时的画面有点 ...
chd114 发表于 2018-3-4 13:26
在退出去的方法里修改选框的位置
真紅樂章 发表于 2018-3-4 15:28
请问可以解说得详细一点吗
比如「@窗口变量名.index=x」要放在脚本的哪里甚麽的
又或 ...
#encoding:utf-8 #============================================================================== # ■ Scene_Item #------------------------------------------------------------------------------ # 物品画面 #============================================================================== class Scene_Item < Scene_ItemBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super create_help_window create_category_window create_item_window end #-------------------------------------------------------------------------- # ● 生成分类窗口 #-------------------------------------------------------------------------- def create_category_window @category_window = Window_ItemCategory.new @category_window.viewport = @viewport @category_window.help_window = @help_window @category_window.y = @help_window.height @category_window.set_handler(:ok, method(:on_category_ok)) @category_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # ● 生成物品窗口 #-------------------------------------------------------------------------- def create_item_window wy = @category_window.y + @category_window.height wh = Graphics.height - wy @item_window = Window_ItemList.new(0, wy, Graphics.width, wh) @item_window.viewport = @viewport @item_window.help_window = @help_window @item_window.set_handler(:ok, method(:on_item_ok)) @item_window.set_handler(:cancel, method(:on_item_cancel)) @category_window.item_window = @item_window end #-------------------------------------------------------------------------- # ● 分类“确定” #-------------------------------------------------------------------------- def on_category_ok @item_window.activate @item_window.select_last end #-------------------------------------------------------------------------- # ● 物品“确定” #-------------------------------------------------------------------------- def on_item_ok $game_party.last_item.object = item determine_item end #-------------------------------------------------------------------------- # ● 物品“取消” #-------------------------------------------------------------------------- def on_item_cancel @item_window.unselect @category_window.activate end #-------------------------------------------------------------------------- # ● 播放使用物品声效 #-------------------------------------------------------------------------- def play_se_for_item Sound.play_use_item end #-------------------------------------------------------------------------- # ● 使用物品 #-------------------------------------------------------------------------- def use_item super @item_window.redraw_current_item end end
chd114 发表于 2018-3-4 18:48
如果你要做的是一个类似物品界面的窗口,那你的场景应该参考这个,而不是每个窗口都弄一个场景,这里面, ...
class Window_SuCommand < Window_HorzCommand #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_reader :scommand_window #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize super(0, 0) end #-------------------------------------------------------------------------- # ● 获取窗口的宽度 #-------------------------------------------------------------------------- def window_width Graphics.width end #-------------------------------------------------------------------------- # ● 获取列数 #-------------------------------------------------------------------------- def col_max return 6 end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- def update super @item_window.category = current_symbol if @item_window end #-------------------------------------------------------------------------- # ● 生成指令列表 #-------------------------------------------------------------------------- def make_command_list add_command("一", :aaa,) add_command("二", :bbb,) add_command("三", :ccc,) add_command("四", :ddd,) add_command("五", :eee,) add_command("六", :fff,) end #-------------------------------------------------------------------------- # ● 设置物品窗口 #-------------------------------------------------------------------------- def scommand_window=(scommand_window) @scommand_window = scommand_window update end end class Scene_scommand < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super create_category_window create_scommand_window end #-------------------------------------------------------------------------- # ● 生成分类窗口 #-------------------------------------------------------------------------- def create_category_window @category_window = Window_SuCommand.new @category_window.viewport = @viewport @category_window.help_window = @help_window @category_window.y = 0 @category_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # ● 生成物品窗口 #-------------------------------------------------------------------------- def create_scommand_window 應該是卡死在這裏了吧? end end
chd114 发表于 2018-3-4 21:14
你删了什么···
class Window_SuCommand < Window_HorzCommand #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_reader :scommand_window #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize super(0, 0) end #-------------------------------------------------------------------------- # ● 获取窗口的宽度 #-------------------------------------------------------------------------- def window_width Graphics.width end #-------------------------------------------------------------------------- # ● 获取列数 #-------------------------------------------------------------------------- def col_max return 6 end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- def update super @item_window.category = current_symbol if @item_window end #-------------------------------------------------------------------------- # ● 生成指令列表 #-------------------------------------------------------------------------- def make_command_list add_command("一", :aaa,) add_command("二", :bbb,) add_command("三", :ccc,) add_command("四", :ddd,) add_command("五", :eee,) add_command("六", :fff,) end #-------------------------------------------------------------------------- # ● 设置物品窗口 #-------------------------------------------------------------------------- def scommand_window=(scommand_window) @scommand_window = scommand_window update end end class Scene_scommand < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super # create_help_window create_category_window create_scommand_window end #-------------------------------------------------------------------------- # ● 生成分类窗口 #-------------------------------------------------------------------------- def create_category_window @category_window = Window_SuCommand.new @category_window.viewport = @viewport @category_window.help_window = @help_window @category_window.y = 0 # @category_window.set_handler(:ok, method(:on_category_ok)) @category_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # ● 生成物品窗口 #-------------------------------------------------------------------------- def create_scommand_window # wh = Graphics.height - wy # @scommand_window = Window_SuCommand.new(0, wy, Graphics.width, wh) # @scommand_window.viewport = @viewport # @scommand_window.help_window = @help_window # @scommand_window.set_handler(:ok, method(:on_scommand_ok)) # @scommand_window.set_handler(:cancel, method(:on_scommand_cancel)) # @category_window.scommand_window = @scommand_window end #-------------------------------------------------------------------------- # ● 分类“确定” #-------------------------------------------------------------------------- # def on_category_ok # @scommand_window.activate # @scommand_window.select_last # end #-------------------------------------------------------------------------- # ● 物品“确定” #-------------------------------------------------------------------------- # def on_item_ok # $game_party.last_item.object = item # determine_item # end #-------------------------------------------------------------------------- # ● 物品“取消” #-------------------------------------------------------------------------- # def on_item_cancel # @item_window.unselect # @category_window.activate # end #-------------------------------------------------------------------------- # ● 播放使用物品声效 #-------------------------------------------------------------------------- # def play_se_for_item # Sound.play_use_item # end #-------------------------------------------------------------------------- # ● 使用物品 #-------------------------------------------------------------------------- # def use_item # super # @item_window.redraw_current_item # end end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |