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

Project1

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

这个是怎么回事?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
1 小时
注册时间
2008-6-28
帖子
86
跳转到指定楼层
1
发表于 2008-7-15 16:39:49 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
脚本‘window_savefile'的53行发生了 NoMethodError.undefined method `+' for nil:NilClass
郁闷了。不能存档和读档。

看看怎么回事?
#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
#  显示存档以及读档画面、保存文件的窗口。
#==============================================================================

class Window_SaveFile < Window_Base
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :filename                 # 文件名
  attr_reader   :selected                 # 选择状态
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     file_index : 存档文件的索引 (0~3)
  #     filename   : 文件名
  #--------------------------------------------------------------------------
  def initialize(file_index, filename)
    super(0, 64 + file_index % 4 * 104, 640, 104)
    self.contents = Bitmap.new(width - 32, height - 32)
    @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
    # 描绘文件编号
    self.contents.font.color = normal_color
    name = "文件 #{@file_index + 1}"
    self.contents.draw_text(4, 0, 600, 32, name)
    @name_width = contents.text_size(name).width
    # 存档文件存在的情况下
    if @file_exist
      # 描绘角色
      for i in [email protected]
        testname = @characters[2]+"_f.png"
        if FileTest.exist?("Graphics/battlers/#{testname}")
          sp = Sprite.new
          sp.bitmap=Bitmap.new("Graphics/battlers/#{testname}")
          sp.zoom_x = 80 / sp.bitmap.width
          sp.zoom_y = 80 / sp.bitmap.height
          src_rect = Rect.new(0, 0, 80, 80) #——可自己调整大小
          x = 300 - @characters.size * 32 + i * 64 - sp.bitmap.width / 2
          self.contents.blt(x, 0, sp.bitmap, src_rect)
        else
          bitmap = RPG::Cache.character(@characters[0], @characters[1])
          cw = bitmap.rect.width / 4
          ch = bitmap.rect.height / 4
          src_rect = Rect.new(0, 0, cw, ch)
          x = 300 - @characters.size * 32 + i * 64 - cw / 2
          self.contents.blt(x, 68 - ch, bitmap, src_rect)
        end
      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(4, 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(4, 40, 600, 32, time_string, 2)
    end
  end
  #--------------------------------------------------------------------------
  # ● 设置选择状态
  #     selected : 新的选择状态 (true=选择 false=不选择)
  #--------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @selected
      self.cursor_rect.set(0, 0, @name_width + 8, 32)
    else
      self.cursor_rect.empty
    end
  end
end

版务信息:本贴由楼主自主结贴~
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-6-14
帖子
35
2
发表于 2008-7-17 21:22:09 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2025-8-9 05:10

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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