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

Project1

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

[已经解决] 截屏存档跳错

[复制链接]

Lv4.逐梦者

梦石
0
星屑
5987
在线时间
1557 小时
注册时间
2011-6-14
帖子
520
跳转到指定楼层
1
发表于 2014-10-15 02:43:46 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
之前用着没事的  求帮看看怎么了
RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],转载和使用请保留此信息
  3. #===============================================================================
  4.  
  5. BBS_66RPG_DIR = "Save/"  # 储存文件夹名,请制作游戏时自行建立此文件夹
  6.  
  7. # 若想使用自定义背景图,脚本62行的井号去掉,并放置一张相应图形。
  8.  
  9. # 在你的Scene_Title中找到这一段(如果使用其他插件脚本,在插件中找):
  10. #    for i in 0..3
  11. #      if FileTest.exist?("Save#{i+1}.rxdata")
  12. # 请自行把0..3改为0..最大进度号,比如0..9
  13. # "Save#{i+1}.rxdata" 改为"Save/Save#{i}.rxdata"
  14.  
  15. # 增加进度的方法:138,258行,继续添加。你也可以改“进度X”为“回忆X”或者“红/绿/蓝笔记本”
  16.  
  17. #===============================================================================
  18. module Screen  
  19.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  20.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  21.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  22.   module_function
  23.   #-----------------------------------------------------------------------------
  24.   # here comes the stuff...
  25.   # i add here the stuff for automatic change of the number for the screenshot
  26.   # so it wont overrite the old one...
  27.   # if you want to change so stuff change them in this line below
  28.   # or you can change them in your command line... like
  29.   # Screen::shot("screenshot", 2)
  30.   # this change the name and the type of the screenshot
  31.   # (0 = bmp, 1 = jpg and 2 = png)
  32.   # ----------------------------------------------------------------------------
  33.   def shot(file = "shot", typ = 1)
  34.     # to add the right extension...
  35.     if typ == 0
  36.       typname = ".bmp"
  37.     elsif typ == 1
  38.       typname = ".jpg"
  39.     elsif typ == 2
  40.       typname = ".png"
  41.     end   
  42.     file_index = 0   
  43.     dir = "Save/"   
  44.     # make the filename....
  45.     file_name = dir + file.to_s + typname.to_s   
  46.     # make the screenshot.... Attention dont change anything from here on....
  47.     @screen.call(0,0,640,480,file_name,handel,typ)
  48.   end
  49.   # find the game window...
  50.   def handel
  51.     game_name = "\0" * 256
  52.     @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  53.     game_name.delete!("\0")
  54.     return @findwindow.call('RGSS Player',game_name)
  55.   end
  56. end
  57.  
  58. class Window_File < Window_Base
  59.   attr_accessor :index
  60.   def initialize(index = 0)
  61.     @backsp = Sprite.new
  62.     #@backsp.bitmap = Bitmap.new("Graphics/Pictures/存盘背景.jpg")
  63.     @backsp.z = 99
  64.     super(160,0,480,480)
  65.     #这行可以不用
  66.     self.contents = Bitmap.new(width - 32, height - 32)
  67.     @index = index
  68.     #这里我要说明一句,之所以用sprite是为了放缩图片
  69.     @sprite = Sprite.new
  70.     @sprite.visible = false
  71.     @sprite.z = 100
  72.     @sp_ch = []
  73.     @sp_ch[0] = Sprite.new
  74.     refresh
  75.   end
  76.   def refresh
  77.     self.contents.clear
  78.     for i in @sp_ch
  79.       i.visible = false
  80.     end
  81.     @sprite.visible = false
  82.     if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.rxdata")
  83.       @sprite.visible = true
  84.       if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.jpg")
  85.         @sprite.bitmap = Bitmap.new(BBS_66RPG_DIR+"Save#{@index}.jpg")
  86.       else
  87.         self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?")
  88.       end
  89.       @sprite.x = 176
  90.       @sprite.y = 16
  91.       @sprite.zoom_x = 0.7
  92.       @sprite.zoom_y = 0.7
  93.       file = File.open(BBS_66RPG_DIR+"Save#{@index}.rxdata", "r")
  94.       @time_stamp = file.mtime
  95.       @characters = Marshal.load(file)
  96.       @frame_count = Marshal.load(file)
  97.       @game_system = Marshal.load(file)
  98.       @game_switches = Marshal.load(file)
  99.       @game_variables = Marshal.load(file)
  100.       @total_sec = @frame_count / Graphics.frame_rate
  101.       file.close
  102.       for i in [email]0...@characters.size[/email]
  103.         @sp_ch[i] = Sprite.new
  104.         @sp_ch[i].visible = true
  105.         @sp_ch[i].bitmap = RPG::Cache.battler(@characters[i][3], @characters[i][4])
  106.         @sp_ch[i].x = 180 + i*100      
  107.         @sp_ch[i].y = 460 - @sp_ch[i].bitmap.height
  108.         @sp_ch[i].z = 101
  109.       end
  110.       # 描绘游戏时间
  111.       hour = @total_sec / 60 / 60
  112.       min = @total_sec / 60 % 60
  113.       sec = @total_sec % 60
  114.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  115.       self.contents.font.color = normal_color
  116.       self.contents.draw_text(4, 390, 420, 32, time_string, 2)
  117.       # 描绘时间标记
  118.       self.contents.font.color = normal_color
  119.       time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  120.       self.contents.draw_text(4, 420, 420, 32, time_string, 2)
  121.     else
  122.       self.contents.draw_text(32,32,420,32,"这个存档是空的")
  123.     end
  124.   end
  125.   def dispose
  126.     super
  127.     @sprite.dispose
  128.     @backsp.dispose
  129.     for i in @sp_ch
  130.       i.dispose
  131.     end
  132.   end
  133. end
  134.  
  135.  
  136. class Scene_Save
  137.   def main
  138.     @command_window = Window_Command.new(160,["进度一","进度二","进度三","进度四","进度五","进度六"])
  139.     @command_window.y = 96
  140.     @command_window.index = $game_temp.last_file_index
  141.     @content_window = Window_File.new($game_temp.last_file_index)
  142.     # 执行过渡
  143.     Graphics.transition
  144.     # 主循环
  145.     loop do
  146.       # 刷新游戏画面
  147.       Graphics.update
  148.       # 刷新输入信息
  149.       Input.update
  150.       # 刷新画面
  151.       update
  152.       # 如果画面被切换的话就中断循环
  153.       if $scene != self
  154.         break
  155.       end
  156.     end
  157.     # 准备过渡
  158.     Graphics.freeze
  159.     @command_window.dispose
  160.     @content_window.dispose
  161.   end
  162.   def update
  163.     @command_window.update   
  164.     if @command_window.index != @content_window.index
  165.       @content_window.index = @command_window.index
  166.       @content_window.refresh
  167.     end   
  168.     #——————下面这一部分是原装脚本——————#
  169.     if Input.trigger?(Input::B)  
  170.       $game_system.se_play($data_system.cancel_se)
  171.       if $game_temp.save_calling
  172.         $game_temp.save_calling = false
  173.         $scene = Scene_Map.new
  174.         return
  175.       end
  176.       $scene = Scene_Menu.new(4)
  177.     end   
  178.     #———————————————————————#   
  179.     if Input.trigger?(Input::C)
  180.       # 演奏存档 SE
  181.       $game_system.se_play($data_system.save_se)
  182.       # 写入存档数据
  183.       file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "wb")
  184.       write_save_data(file)
  185.       if FileTest.exist?(BBS_66RPG_DIR+"shot.jpg")
  186.         File.rename(BBS_66RPG_DIR+"shot.jpg", BBS_66RPG_DIR+"Save#{@command_window.index}.jpg")
  187.       end
  188.       file.close
  189.       $game_temp.last_file_index = @command_window.index
  190.       # 如果被事件调用
  191.       if $game_temp.save_calling
  192.         # 清除存档调用标志
  193.         $game_temp.save_calling = false
  194.         # 切换到地图画面
  195.         $scene = Scene_Map.new
  196.         return
  197.       end
  198.       # 切换到菜单画面
  199.       $scene = Scene_Map.new
  200.     end
  201.     #———————————————————————#
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ● 写入存档数据
  205.   #     file : 写入用文件对像 (已经打开)
  206.   #--------------------------------------------------------------------------
  207.   def write_save_data(file)
  208.     # 生成描绘存档文件用的角色图形
  209.     characters = []
  210.     for i in 0...$game_party.actors.size
  211.       actor = $game_party.actors[i]
  212.       characters.push([actor.character_name, actor.character_hue, actor.id, actor.battler_name, actor.battler_hue])
  213.     end
  214.     # 写入描绘存档文件用的角色数据
  215.     Marshal.dump(characters, file)
  216.     # 写入测量游戏时间用画面计数
  217.     Marshal.dump(Graphics.frame_count, file)
  218.     # 增加 1 次存档次数
  219.     $game_system.save_count += 1
  220.     # 保存魔法编号
  221.     # (将编辑器保存的值以随机值替换)
  222.     $game_system.magic_number = $data_system.magic_number
  223.     # 写入各种游戏对像
  224.     Marshal.dump($game_system, file)
  225.     Marshal.dump($game_switches, file)
  226.     Marshal.dump($game_variables, file)
  227.     Marshal.dump($game_self_switches, file)
  228.     Marshal.dump($game_screen, file)
  229.     Marshal.dump($game_actors, file)
  230.     Marshal.dump($game_party, file)
  231.     Marshal.dump($game_troop, file)
  232.     Marshal.dump($game_map, file)
  233.     Marshal.dump($game_player, file)
  234.   end
  235. end
  236.  
  237.  
  238. class Scene_Load
  239.   def initialize
  240.     # 再生成临时对像
  241.     $game_temp = Game_Temp.new
  242.     # 选择存档时间最新的文件
  243.     $game_temp.last_file_index = 0
  244.     latest_time = Time.at(0)
  245.     for i in 0..6
  246.       filename = BBS_66RPG_DIR+"Save#{i}.rxdata"
  247.       if FileTest.exist?(filename)
  248.         file = File.open(filename, "r")
  249.         if file.mtime > latest_time
  250.           latest_time = file.mtime
  251.           $game_temp.last_file_index = i
  252.         end
  253.         file.close
  254.       end
  255.     end
  256.   end  
  257.   def main
  258.     @command_window = Window_Command.new(160,["进度一","进度二","进度三","进度四","进度五","进度六"])
  259.     @command_window.y = 96
  260.     @command_window.index = $game_temp.last_file_index
  261.     @content_window = Window_File.new($game_temp.last_file_index)
  262.     # 执行过渡
  263.     Graphics.transition
  264.     # 主循环
  265.     loop do
  266.       # 刷新游戏画面
  267.       Graphics.update
  268.       # 刷新输入信息
  269.       Input.update
  270.       # 刷新画面
  271.       update
  272.       # 如果画面被切换的话就中断循环
  273.       if $scene != self
  274.         break
  275.       end
  276.     end
  277.     # 准备过渡
  278.     Graphics.freeze
  279.     @command_window.dispose
  280.     @content_window.dispose
  281.   end
  282.   def update
  283.     @command_window.update   
  284.     if @command_window.index != @content_window.index
  285.       @content_window.index = @command_window.index
  286.       @content_window.refresh
  287.     end   
  288.     #——————下面这一部分是原装脚本——————#
  289.     if Input.trigger?(Input::B)  
  290.     # 演奏取消 SE
  291.     $game_system.se_play($data_system.cancel_se)
  292.     if $titleing
  293.       $scene = Scene_Title.new
  294.     else
  295.       $scene = Scene_Map.new
  296.     end
  297.     end   
  298.     #———————————————————————#   
  299.     if Input.trigger?(Input::C)
  300.       # 文件不存在的情况下
  301.       unless FileTest.exist?(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata")
  302.         # 演奏冻结 SE
  303.         $game_system.se_play($data_system.buzzer_se)
  304.         return
  305.       end
  306.       # 演奏读档 SE
  307.       $game_system.se_play($data_system.load_se)
  308.       # 写入存档数据
  309.       file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "rb")
  310.       read_save_data(file)
  311.       file.close
  312.       # 还原 BGM、BGS
  313.       $game_system.bgm_play($game_system.playing_bgm)
  314.       $game_system.bgs_play($game_system.playing_bgs)
  315.       # 刷新地图 (执行并行事件)
  316.       $game_map.update
  317.       # 切换到地图画面
  318.       $scene = Scene_Map.new
  319.     end
  320.     #———————————————————————#
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● 写入存档数据
  324.   #     file : 写入用文件对像 (已经打开)
  325.   #--------------------------------------------------------------------------
  326.   def read_save_data(file)
  327.     # 读取描绘存档文件用的角色数据
  328.     characters = Marshal.load(file)
  329.     # 读取测量游戏时间用画面计数
  330.     Graphics.frame_count = Marshal.load(file)
  331.     # 读取各种游戏对像
  332.     $game_system        = Marshal.load(file)
  333.     $game_switches      = Marshal.load(file)
  334.     $game_variables     = Marshal.load(file)
  335.     $game_self_switches = Marshal.load(file)
  336.     $game_screen        = Marshal.load(file)
  337.     $game_actors        = Marshal.load(file)
  338.     $game_party         = Marshal.load(file)
  339.     $game_troop         = Marshal.load(file)
  340.     $game_map           = Marshal.load(file)
  341.     $game_player        = Marshal.load(file)
  342.     # 魔法编号与保存时有差异的情况下
  343.     # (加入编辑器的编辑过的数据)
  344.     if $game_system.magic_number != $data_system.magic_number
  345.       # 重新装载地图
  346.       $game_map.setup($game_map.map_id)
  347.       $game_player.center($game_player.x, $game_player.y)
  348.     end
  349.     # 刷新同伴成员
  350.     $game_party.refresh
  351.   end
  352. end
  353.  
  354. class Scene_Menu
  355.   alias bbs_66rpg_shotsave_main main
  356.   def main
  357.     if @menu_index == 0
  358.       Screen::shot
  359.     end   
  360.     bbs_66rpg_shotsave_main
  361.   end
  362. end
  363.  
  364. class Interpreter
  365.   #--------------------------------------------------------------------------
  366.   # ● 调用存档画面
  367.   #--------------------------------------------------------------------------
  368.   def command_352
  369.     # 设置战斗中断标志
  370.     $game_temp.battle_abort = true
  371.     # 设置调用存档标志
  372.     $game_temp.save_calling = true
  373.     # 推进索引
  374.     @index += 1
  375.     # 结束
  376.     Screen::shot
  377.     return false
  378.   end
  379. end

Lv3.寻梦者

灌水局大小姐

梦石
0
星屑
3810
在线时间
1690 小时
注册时间
2012-3-10
帖子
2469
2
发表于 2014-10-15 06:02:21 | 只看该作者
在游戏目录里新建“Save”文件夹了吗?

点评

早有了,之前我还是能顺利存档的  发表于 2014-10-15 08:59
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
5987
在线时间
1557 小时
注册时间
2011-6-14
帖子
520
3
 楼主| 发表于 2014-10-15 10:47:53 | 只看该作者
怎么我删了这个脚本原来内置的存档这里也会出错
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (版主)

梦石
0
星屑
9532
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

4
发表于 2014-10-15 14:26:24 | 只看该作者
从报错信息来看,是将一个Sprite类对象写入文件,这是不可以的,因为Sprite对象是不能保存的,当强行对Sprite对象使用Marshal.dump时,会发生TypeError。
再看224行,Marshal.dump($game_system, file),意思是把$game_system这个对象写入文件,$game_system本身不是Sprite对象,但是如果它内部的成员是Sprite对象,也会引发此异常。而贴出的存档脚本没有对Game_System作更改,所以,是不是别的脚本对Game_System类结构做出的改造呢?(敢在Game_System里面加Sprite其实是个作死的做法)全局搜索“class Game_System”,看看是哪个脚本改过它吧。
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
5987
在线时间
1557 小时
注册时间
2011-6-14
帖子
520
5
 楼主| 发表于 2014-10-15 14:45:44 | 只看该作者
RyanBern 发表于 2014-10-15 14:26
从报错信息来看,是将一个Sprite类对象写入文件,这是不可以的,因为Sprite对象是不能保存的,当强行对Spri ...

是Fuki呢 ,不过奇怪的是我之前在使用工程中不曾出现过这个问题
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (版主)

梦石
0
星屑
9532
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

6
发表于 2014-10-15 19:32:39 | 只看该作者
347780682 发表于 2014-10-15 14:45
是Fuki呢 ,不过奇怪的是我之前在使用工程中不曾出现过这个问题

你可以把脚本文件Scripts.rxdata上传,我们看看到底是哪里的问题

点评

非常感谢你帮了我。因为可能觉得解决不了,我把脚本删了。现在没有问题了  发表于 2014-10-15 20:44
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-21 21:54

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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