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

Project1

 找回密码
 注册会员
搜索

脚本报错求指导

查看数: 2065 | 评论数: 9 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
yue
发布时间: 2014-1-7 18:42

正文摘要:

公共事件菜单 + 原版读档界面 读档很顺利,进入地图了(看过66的视频) 但是报错了很烦躁 如图 请问是怎么解决   另外贴上我的window_bass RUBY 代码复制#================ ...

回复

yue 发表于 2014-1-7 22:25:12
恋′挂机 发表于 2014-1-7 22:17
惭愧,只是简单的容错具体原因不详。。。

不过我试了下,只要在呼出存档界面下方不中断循环就可以了

ok  已经解决   谢谢了
恐惧剑刃 发表于 2014-1-7 22:17:59
本帖最后由 恋′挂机 于 2014-1-7 22:24 编辑
yue 发表于 2014-1-7 21:55
是了!   能深究一下这两个地方的不同之处么??


惭愧,只是简单的容错具体原因不详。。。

不过我试了下,只要在呼出存档界面下方不中断循环就可以了


放在Scene_Map中试试吧

在main生成信息窗口下方
$gold = Window_Gold.new
$gold.x = xxxx # 你设置的值
$gold.y = xxxx# 你设置的值
$gold.opacity = xxx# 你设置的值
$gold.visible = false
释放那里
$gold.dispose
这样可能会解决。
然后在事件中就不要用那些脚本了
了事件渐变中的脚本(进入菜单)$gold.visible = true
原来释放那里$gold.visible = false
yue 发表于 2014-1-7 21:55:52
恋′挂机 发表于 2014-1-7 21:52
把你的释放脚本改为看看是不是这里的问题

是了!   能深究一下这两个地方的不同之处么??
恐惧剑刃 发表于 2014-1-7 21:52:28
yue 发表于 2014-1-7 21:30
我把有关的窗口都贴出来吧

这是压缩文件

把你的释放脚本改为
  1. begin
  2. $gold_window.dispose
  3. rescue
  4. end
复制代码
看看是不是这里的问题

评分

参与人数 1星屑 +80 收起 理由
︶ㄣ牛排ぶ + 80 认可答案

查看全部评分

恐惧剑刃 发表于 2014-1-7 20:45:50
本帖最后由 恋′挂机 于 2014-1-7 20:51 编辑
yue 发表于 2014-1-7 20:33
打星星标记的是加上去的   是这里的缘故??


这个没有问题
另外生成背景图的话最好在Scene_File类中生成
main执行过渡前 a = Sprite.new
a.bitmap = Bitmap.new .....
释放那里
a.dispose

好像都不是啊。。。。
因为窗口多次释放导致的问题,检查下你哪里用的dispose了就可以了吧
yue 发表于 2014-1-7 20:42:47
恋′挂机 发表于 2014-1-7 19:33
窗口已经被释放,所以不具有contents属性
请把你改的场景或窗口脚本放出来
  1. #==============================================================================
  2. # ■ Window_SaveFile
  3. #------------------------------------------------------------------------------
  4. #  显示存档以及读档画面、保存文件的窗口。
  5. #==============================================================================

  6. class Window_SaveFile < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 定义实例变量
  9.   #--------------------------------------------------------------------------
  10.   attr_reader   :filename                 # 文件名
  11.   attr_reader   :selected                 # 选择状态
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化对像
  14.   #     file_index : 存档文件的索引 (0~3)
  15.   #     filename   : 文件名
  16.   #--------------------------------------------------------------------------
  17.   def initialize(file_index, filename)
  18.     super(0, 64 + file_index % 4 * 104, 640, 104)
  19.     self.contents = Bitmap.new(width - 32, height - 32)
  20.     @file_index = file_index
  21.     @filename = "Save#{@file_index + 1}.rxdata"
  22.     @time_stamp = Time.at(0)
  23.     @file_exist = FileTest.exist?(@filename)
  24.     if @file_exist
  25.       file = File.open(@filename, "r")
  26.       @time_stamp = file.mtime
  27.       @characters = Marshal.load(file)
  28.       @frame_count = Marshal.load(file)
  29.       @game_system = Marshal.load(file)
  30.       @game_switches = Marshal.load(file)
  31.       @game_variables = Marshal.load(file)
  32.       @total_sec = @frame_count / Graphics.frame_rate
  33.       file.close
  34.     end
  35.     refresh
  36.     @selected = false
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 刷新
  40.   #--------------------------------------------------------------------------
  41.   def refresh
  42.     self.contents.clear
  43.     # 描绘文件编号
  44.     self.contents.font.color = normal_color
  45.     name = "文件 #{@file_index + 1}"
  46.     self.contents.draw_text(4, 0, 600, 32, name)
  47.     @name_width = contents.text_size(name).width
  48.     # 存档文件存在的情况下
  49.     if @file_exist
  50.       # 描绘角色*****************************************************************
  51.       for i in [email protected]*************************************************
  52.         bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])********************
  53.         cw = bitmap.rect.width / 4*************************************************
  54.         ch = bitmap.rect.height / 4****************************************************
  55.         src_rect = Rect.new(0, 0, cw, ch)*******************************************
  56.         x = 300 - @characters.size * 32 + i * 64 - cw / 2*****************************
  57.         self.contents.blt(x, 68 - ch, bitmap, src_rect)**********************************
  58.       end******************************************************************
  59.       # 描绘游戏时间
  60.       hour = @total_sec / 60 / 60
  61.       min = @total_sec / 60 % 60
  62.       sec = @total_sec % 60
  63.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  64.       self.contents.font.color = normal_color
  65.       self.contents.draw_text(4, 8, 600, 32, time_string, 2)
  66.       # 描绘时间标记
  67.       self.contents.font.color = normal_color
  68.       time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  69.       self.contents.draw_text(4, 40, 600, 32, time_string, 2)
  70.     end
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 设置选择状态
  74.   #     selected : 新的选择状态 (true=选择 false=不选择)
  75.   #--------------------------------------------------------------------------
  76.   def selected=(selected)
  77.     @selected = selected
  78.     update_cursor_rect
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 刷新光标矩形
  82.   #--------------------------------------------------------------------------
  83.   def update_cursor_rect
  84.     if @selected
  85.       self.cursor_rect.set(0, 0, @name_width + 8, 32)
  86.     else
  87.       self.cursor_rect.empty
  88.     end
  89.   end
  90. end
复制代码
这里面删去了星标部分,是不是这个的问题
yue 发表于 2014-1-7 20:33:20
恋′挂机 发表于 2014-1-7 19:33
窗口已经被释放,所以不具有contents属性
请把你改的场景或窗口脚本放出来
  1. class Scene_Load < Scene_File
  2.   #--------------------------------------------------------------------------
  3.   # ● 初始化对像
  4.   #--------------------------------------------------------------------------
  5.   def initialize
  6.     # 再生成临时对像
  7.     $game_temp = Game_Temp.new
  8.     $devil = Sprite.new*************************************************************
  9.     $devil.bitmap = Bitmap.new("Graphics/Pictures/读档界面.png") *************************
  10.     # 选择存档时间最新的文件
  11.     $game_temp.last_file_index = 0
  12.     latest_time = Time.at(0)
  13.     for i in 0..3
  14.       filename = make_filename(i)
  15.       if FileTest.exist?(filename)
  16.         file = File.open(filename, "r")
  17.         if file.mtime > latest_time
  18.           latest_time = file.mtime
  19.           $game_temp.last_file_index = i
  20.         end
  21.         file.close
  22.       end
  23.     end
  24.     super("要载入哪个文件?")
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 确定时的处理
  28.   #--------------------------------------------------------------------------
  29.   def on_decision(filename)
  30.     # 文件不存在的情况下
  31.     unless FileTest.exist?(filename)
  32.       # 演奏冻结 SE
  33.       $game_system.se_play($data_system.buzzer_se)
  34.       return
  35.     end
  36.     # 演奏读档 SE
  37.     $game_system.se_play($data_system.load_se)
  38.     # 写入存档数据
  39.     file = File.open(filename, "rb")
  40.     read_save_data(file)
  41.     file.close
  42.     # 还原 BGM、BGS
  43.     $game_system.bgm_play($game_system.playing_bgm)
  44.     $game_system.bgs_play($game_system.playing_bgs)
  45.     # 刷新地图 (执行并行事件)
  46.     $game_map.update
  47.     # 物品窗口界面透明
  48.     $game_screen.pictures[3].erase
  49.     # 切换到地图画面
  50.     $scene = Scene_Map.new
  51.     # 释放窗口
  52.    
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 取消时的处理
  56.   #--------------------------------------------------------------------------
  57.   def on_cancel
  58.     # 演奏取消 SE
  59.     $game_system.se_play($data_system.cancel_se)
  60.     # 切换到标题画面
  61.     $scene = Scene_Title.new
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● 读取存档数据
  65.   #     file : 读取用文件对像 (已经打开)
  66.   #--------------------------------------------------------------------------
  67.   def read_save_data(file)
  68.     # 读取描绘存档文件用的角色数据
  69.     characters = Marshal.load(file)
  70.     # 读取测量游戏时间用画面计数
  71.     Graphics.frame_count = Marshal.load(file)
  72.     # 读取各种游戏对像
  73.     $game_system        = Marshal.load(file)
  74.     $game_switches      = Marshal.load(file)
  75.     $game_variables     = Marshal.load(file)
  76.     $game_self_switches = Marshal.load(file)
  77.     $game_screen        = Marshal.load(file)
  78.     $game_actors        = Marshal.load(file)
  79.     $game_party         = Marshal.load(file)
  80.     $game_troop         = Marshal.load(file)
  81.     $game_map           = Marshal.load(file)
  82.     $game_player        = Marshal.load(file)
  83.     # 魔法编号与保存时有差异的情况下
  84.     # (加入编辑器的编辑过的数据)
  85.     if $game_system.magic_number != $data_system.magic_number
  86.       # 重新装载地图
  87.       $game_map.setup($game_map.map_id)
  88.       $game_player.center($game_player.x, $game_player.y)
  89.     end
  90.     # 刷新同伴成员
  91.     $game_party.refresh
  92.   end
  93. end
复制代码
打星星标记的是加上去的   是这里的缘故??
恐惧剑刃 发表于 2014-1-7 19:33:24
本帖最后由 恋′挂机 于 2014-1-7 19:41 编辑

窗口已经被释放,所以不具有contents属性
请把你改的场景或窗口脚本放出来

你检查下,在一个场景中是否释放了二次同一个 窗口
甚至把 xxx.dispose 放在了 update 里

这两种情况都会导致这种问题
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-9-21 08:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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