注册会员 登录
Project1 返回首页

蒟蒻果冻 https://rpg.blue/?293757 [收藏] [复制] [分享] [RSS] blog: http://sxysxy.org

日志

扩展菜单脚本

已有 192 次阅读2015-8-10 11:04 |个人分类:脚本| 菜单

学了c,c++,汇编之后,好久没碰ruby了,偶然打开rmva才想起来,我最初学编程就是接触的这个rmva,那时只是想制作自己的游戏,哎,好好的游戏制作者变成码农了。。。忽然心血来潮,当初看不太懂的脚本现在再看会有什么感觉呢?我看了看va原先自带的脚本,感觉忽然又喜欢上用ruby了,也想试试自己制作脚本。于是先拿这个游戏菜单开刀了。

脚本内容如下:额,其实如果只是扩展游戏时间窗口,选项列表,用不了这么多代码,但我还是选择重头写这个菜单,主要是为了熟悉ruby和RGSS,另外就是这样有成就感

#encoding:utf-8
#扩展游戏菜单
#  #扩展内容
#   1.扩展菜单选项
#   2.增加游戏时间窗口
#   3.记得改下Scene_Map第193行,那里的调用菜单的部分,改为
#               SceneManager.call(Scene_MyMenu)
#   4.这个脚本不能与原自带的Scene_Menu共存!
#                                               浮云半仙 2015.08.09
#-----------------------------------------------------------------------------
class Window_MyMenuCommand < Window_Command
  def initialize
    super(0,0)
    update_placement
    open
  end
  def make_command_list
    add_all_command
  end
  def add_all_command
    add_command("物品", :item)
    add_command("装备", :equip)
    add_command("状态", :status)
    add_command("技能", :skill)
    add_command("图鉴", :dictionary)
    add_command("帮助", :help)
    add_command("关于", :about)
    add_command("存档", :save,ok_to_save?)
    add_command("读档", :load)
    add_command("结束", :end)
  end
  def window_width
    return 140
  end
  def update_placement
    self.x = 0
    self.y = 0
  end
  def ok_to_save?
    !$game_system.save_disabled
  end
end
#---------------------------------------------------------------------------
class Window_ShowPlayTime < Window_Help
  attr_reader :sec
  def initialize
    super(2)
    refresh
    open
  end
  def update
    super
    refresh if Graphics.frame_count / Graphics.frame_rate != @sec
              #过了1秒,刷新
  end
  def refresh
    @sec = Graphics.frame_count / Graphics.frame_rate
    @text = sprintf("游戏时间:\n%02d:%02d:%02d", @sec/60/60, @sec/60, @sec%60)
    super
  end     
end

#----------------------------------------------------------------------------
class Scene_Menu < Scene_Base
  def start
    super
    create_command_window
    create_time_window
    create_gold_window
    create_status_window
  end
  def update
    update_basic
  end
  def create_command_window
    @window_command = Window_MyMenuCommand.new
    @window_command.set_handler(:item,      method(:choose_item))
    @window_command.set_handler(:equip,     method(:choose_personal_option))
    @window_command.set_handler(:status,    method(:choose_personal_option))
    @window_command.set_handler(:skill,     method(:choose_personal_option))
    @window_command.set_handler(:dictionary,method(:choose_dictionary))
    @window_command.set_handler(:help,      method(:choose_help))
    @window_command.set_handler(:about,     method(:choose_about))
    @window_command.set_handler(:save,      method(:choose_save))
    @window_command.set_handler(:load,      method(:choose_load))
    @window_command.set_handler(:end,       method(:choose_end))
    @window_command.set_handler(:cancel,    method(:return_scene))
  end
  def choose_item
    SceneManager.call(Scene_Item)
  end
  def choose_personal_option
    @window_menustatus.select_last
    @window_menustatus.activate
    @window_menustatus.set_handler(:ok,     method(:on_personal_ok))
    @window_menustatus.set_handler(:cancel, method(:on_personal_cancel))
  end
  def on_personal_ok
    case @window_command.current_symbol
    when :skill
      SceneManager.call(Scene_Skill)
    when :equip
      SceneManager.call(Scene_Equip)
    when :status
      SceneManager.call(Scene_Status)
    end
  end
  def on_personal_cancel
    @window_menustatus.unselect
    @window_command.activate
  end
  def choose_dictionary
    @window_command.activate     #先暂时什么都不做
  end
  def choose_help
    @window_command.activate
  end
  def choose_about
    SceneManager.call(Scene_About)
  end
  def choose_save
    SceneManager.call(Scene_Save)
  end
  def choose_load
    SceneManager.call(Scene_Load)
  end
  def choose_end
    SceneManager.call(Scene_End)
  end
  def create_gold_window
    @window_gold = Window_Gold.new
    @window_gold.width = @window_command.width
    @window_gold.height = Graphics.height - @window_command.height \
                                - @window_showplaytime.height
    @window_gold.x = 0
    @window_gold.y = @window_command.height + @window_showplaytime.height
  end
  def create_status_window
    @window_menustatus = Window_MenuStatus.new(@window_command.width,0)
    @window_menustatus.width = Graphics.width - @window_command.width
    @window_menustatus.height = Graphics.height
  end
  def create_time_window
    @window_showplaytime = Window_ShowPlayTime.new
    @window_showplaytime.x = 0
    @window_showplaytime.y = @window_command.height
    @window_showplaytime.width = @window_command.width
    @window_showplaytime.height = 80
  end
end


鸡蛋

鲜花

全部作者的其他最新日志

评论 (0 个评论)

facelist doodle 涂鸦笔

您需要登录后才可以评论 登录 | 注册会员

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-4-21 00:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部