切換
舊版
前往
大廳
主題

遊戲創作-freeway--rpgxp---存檔改造

樟善 | 2016-11-19 15:06:13 | 巴幣 2 | 人氣 597

為了讓存檔畫面更精美,變成這樣:

這次必須更動的是:Window_SaveFile
腳本改造如下:
# ● 初始化目標
  #     file_index : 存檔文件的索引 (0~3)
  #     filename   : 文件名稱
  #--------------------------------------------------------------------------
  def initialize(file_index, filename)
    super(0, 0 + file_index % 1 * 416, 640, 480)
    self.contents = Bitmap.new(width - 10, height - 10)
    @file_index = file_index
    @filename = "Save#{@file_index + 1}.rxdata"
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, "r")
      @time_stamp = file.mtime
      @characters = Marshal.load(file)
      @frame_count = Marshal.load(file)
      @game_system = Marshal.load(file)
      @game_switches = Marshal.load(file)
      @game_variables = Marshal.load(file)
      @total_sec = @frame_count / Graphics.frame_rate
      file.close
    end
    refresh
    @selected = false
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # 描繪文件編號
    name = "記錄回憶"
    self.contents.draw_text(1, 0, 600, 32, name)
    @name_width = contents.text_size(name).width
    # 存檔文件存在的情況下
    if @file_exist
      # 描繪角色
    for i in 0...@characters.size
    bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
    cw = bitmap.rect.width / 4
    ch = bitmap.rect.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    x = 200 - @characters.size * 11 + i * 40 - cw / 2
    self.contents.blt(x+100, 450 - ch, bitmap, src_rect)
    end
      # 描繪遊戲時間
      hour = @total_sec / 60 / 60
      min = @total_sec / 60 % 60
      sec = @total_sec % 60
      time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
      self.contents.font.color = normal_color
      self.contents.draw_text(1, 8, 600, 32, time_string, 2)
      # 描繪時間標記
      self.contents.font.color = normal_color
      time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
      self.contents.draw_text(1, 40, 600, 32, time_string, 2)
    end
  end
然後再到Scene_Save腳本,修改:
# ● 初始化目標
  #--------------------------------------------------------------------------
  def initialize
  super("")
  end
以上,便能夠有大圖的存檔囉!

創作回應

更多創作