Project1

标题: 能不能再退出游戏的时候自动存档 [打印本页]

作者: j1747532399l    时间: 2015-10-2 16:22
标题: 能不能再退出游戏的时候自动存档
  1. class Scene_Save
  2.   def autosave
  3.     # 存档写在 1 号位上,如果写在其他位置要改变这个文件名。
  4.     filename = "Save1.rxdata"
  5.     file = File.open(filename, "wb")
  6.     write_save_data(file)
  7.     file.close
  8.   end
  9. end
  10. module Kernel
  11.   alias rb_exit_20150904 exit
  12.   def exit(n)
  13.     save = Scene_Save.new
  14.     save.autosave
  15.     rb_exit_20150904(n)
  16.   end
  17. end
复制代码
这个是关闭游戏窗口的时候会自动存档的。点击游戏里的 退出 就不会自动存档,求大神在改下{:2_276:}
@RyanBern  
作者: 冷峻逸    时间: 2015-10-2 19:25
提示: 作者被禁止或删除 内容自动屏蔽
作者: 汪汪    时间: 2015-10-2 20:46
本帖最后由 汪汪 于 2015-10-2 20:49 编辑

class Scene_End中


def update
    # 刷新命令窗口
    @command_window.update
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 切换到菜单画面
      $scene = Scene_Menu.new(5)
      return
    end
    # 按下 C 键的场合下
    if Input.trigger?(Input::C)
      # 命令窗口光标位置分支
      case @command_window.index
      when 0  # 返回标题画面
        command_to_title
      when 1  # 退出
        command_shutdown
      when 2  # 取消
        command_cancel
      end
      return
    end
  end

改成

def update
    # 刷新命令窗口
    @command_window.update
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 切换到菜单画面
      $scene = Scene_Menu.new(5)
      return
    end
    # 按下 C 键的场合下
    if Input.trigger?(Input::C)
      # 命令窗口光标位置分支
      case @command_window.index
      when 0  # 返回标题画面
         save = Scene_Save.new
         save.autosave
        command_to_title
      when 1  # 退出
         save = Scene_Save.new
         save.autosave
        command_shutdown
      when 2  # 取消
        command_cancel
      end
      return
    end
  end


另外 建议

module Kernel
  alias rb_exit_20150904 exit
  def exit(n)
    if $game_temp != nil        #建议加上一个游戏是否开始的判断.....不然未开始就关闭会弹出对话框什么的,影响感觉....
    save = Scene_Save.new
    save.autosave
    end
    rb_exit_20150904(n)
  end
end




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