设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1439|回复: 0
打印 上一主题 下一主题

[子弹君] 解谜用简单菜单

[复制链接]

卑微的梦

梦石
0
星屑
511
在线时间
820 小时
注册时间
2013-2-23
帖子
1185

短篇九勇士组季军

跳转到指定楼层
1
发表于 2014-9-27 10:45:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
  1. #=============================================================================
  2. #  解谜用简单菜单  by 子弹君
  3. #=============================================================================
  4. #=============================================================================
  5. #  说明:
  6. #  连module都没设置我是不是很懒啊= =
  7. #  现在这个属于基础版本,未来有时间再优化吧
  8. #=============================================================================
  9. class Scene_Menu < Scene_MenuBase
  10.   #--------------------------------------------------------------------------
  11.   # ● 开始处理
  12.   #--------------------------------------------------------------------------
  13.   def start
  14.     super
  15.     create_command_window
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 生成指令窗口
  19.   #--------------------------------------------------------------------------
  20.   def create_command_window
  21.     @command_window = Window_MenuCommand.new
  22.     @command_window.set_handler(:item,      method(:command_item))
  23.     @command_window.set_handler(:save,      method(:command_save))
  24.     @command_window.set_handler(:game_end,  method(:command_game_end))
  25.     @command_window.set_handler(:cancel,    method(:return_scene))
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 指令“物品”
  29.   #--------------------------------------------------------------------------
  30.   def command_item
  31.     SceneManager.call(Scene_Item)
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● 指令“存档”
  35.   #--------------------------------------------------------------------------
  36.   def command_save
  37.     SceneManager.call(Scene_Save)
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● 指令“结束游戏”
  41.   #--------------------------------------------------------------------------
  42.   def command_game_end
  43.     SceneManager.call(Scene_End)
  44.   end
  45. end
  46. class Window_MenuCommand < Window_Command
  47.   #--------------------------------------------------------------------------
  48.   # ● 初始化指令选择位置(类方法)
  49.   #--------------------------------------------------------------------------
  50.   def self.init_command_position
  51.     @@last_command_symbol = nil
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● 初始化对象
  55.   #--------------------------------------------------------------------------
  56.   def initialize
  57.     super(0, 0)
  58.     update_placement
  59.     select_last
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 获取窗口的宽度
  63.   #--------------------------------------------------------------------------
  64.   def window_width
  65.     return 160
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 更新窗口的位置
  69.   #--------------------------------------------------------------------------
  70.   def update_placement
  71.     self.x = (Graphics.width - width) / 2
  72.     self.y = (Graphics.height - height) / 2
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● 获取显示行数
  76.   #--------------------------------------------------------------------------
  77.   def visible_line_number
  78.     item_max
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 生成指令列表
  82.   #--------------------------------------------------------------------------
  83.   def make_command_list
  84.     add_main_commands
  85.     add_original_commands
  86.     add_save_command
  87.     add_game_end_command
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ● 向指令列表添加主要的指令
  91.   #--------------------------------------------------------------------------
  92.   def add_main_commands
  93.     add_command(Vocab::item,   :item,   main_commands_enabled)
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● 添加存档指令
  97.   #--------------------------------------------------------------------------
  98.   def add_save_command
  99.     add_command(Vocab::save, :save, save_enabled)
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ● 添加游戏结束指令
  103.   #--------------------------------------------------------------------------
  104.   def add_game_end_command
  105.     add_command(Vocab::game_end, :game_end)
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 获取主要指令的有效状态
  109.   #--------------------------------------------------------------------------
  110.   def main_commands_enabled
  111.     $game_party.exists
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 获取存档的有效状态
  115.   #--------------------------------------------------------------------------
  116.   def save_enabled
  117.     !$game_system.save_disabled
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 按下确定键时的处理
  121.   #--------------------------------------------------------------------------
  122.   def process_ok
  123.     @@last_command_symbol = current_symbol
  124.     super
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 返回最后一个选项的位置
  128.   #--------------------------------------------------------------------------
  129.   def select_last
  130.     select_symbol(@@last_command_symbol)
  131.   end
  132. end
复制代码
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-25 17:48

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表