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

Project1

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

[已经解决] 关于截图存取档的一个小问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
381 小时
注册时间
2012-8-13
帖子
113
跳转到指定楼层
1
发表于 2012-8-18 14:28:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我用的是‘Sherryx整合测试版1.01’里整合的‘截图存取档’脚本:

http://rpg.blue/upload_program/files/Sherryx整合测试版1.01.rar

同时我也自己导入了一个中文输入的脚本用来测试角色改名(例如允许玩家在开始新游戏的时候输入主角的姓名),这个时候问题来了,由于截图存取档脚本是根据角色姓名调用\Graphics\Battlers\下同名的_f.png图片作为存档显示头像,因此一旦改名就找不到头像文件了。。。不知道有没有办法可以把这个脚本改动一下,把根据角色名称提取头像文件改为根据角色id(或者直接判定是否主角)来提取呢?

截图存取档的代码在这里:

RUBY 代码复制
  1. ###使用说明
  2. #使用前请复制sceneshot.dll到游戏文件下,并新建文件夹Save
  3. #将此文本插入main前面
  4. #游戏前显示头像的文件名为:人物角色名_f,请自行建立几张做测试,不然找不到图片会报错
  5. #自动存档按钮F5 存入档位0(也就是自动存档那栏)
  6. #使用前,请在菜单脚本:scene_menu里面,
  7. #     when 4 # 存档
  8. #     # 禁止存档的情况下
  9. #     if $game_system.save_disabled
  10. #       # 演奏冻结 SE
  11. #       $game_system.se_play($data_system.buzzer_se)
  12. #       return
  13. #     end
  14. #     # 演奏确定 SE
  15. #     $game_system.se_play($data_system.decision_se)
  16. #     # 切换到存档画面
  17. #     $scene = Scene_Save.new <--这行
  18. #替换为:   $scene = Scene_Loadsave.new
  19. #另,在原scene_title里,48行左右
  20. #    for i in 0..3
  21. #          for i in 0..3
  22. #     if FileTest.exist?("Save#{i+1}.rxdata")
  23. ###################改成if FileTest.exist?("Save/Save#{i+1}.rxdata")
  24. #        @continue_enabled = true
  25. #      end
  26. #    end
  27. #否则继续游戏时会检测不到存档
  28.  
  29. class Window_File < Window_Base
  30. attr_accessor :index
  31. def initialize(index = 0)
  32.    @backsp = Sprite.new
  33.   # @backsp.bitmap = Bitmap.new("Graphics/Pictures/菜单底图.jpg")
  34.    @backsp.z = 100
  35.    super(160,64,480,416)
  36.    #这行可以不用
  37.    self.contents = Bitmap.new(width - 32, height - 32)
  38.    @index = index
  39.    #这里我要说明一句,之所以用sprite是为了放缩图片
  40.    @sprite = Sprite.new
  41.    @sprite.visible = false
  42.    @sprite.z = 100
  43.    @sp_ch = []
  44.    @sp_ch[0] = Sprite.new
  45.    refresh
  46. end
  47. def refresh
  48.    self.contents.clear
  49.    for i in @sp_ch
  50.      i.visible = false
  51.    end
  52.    @sprite.visible = false
  53.    if FileTest.exist?(DIR+"Save#{@index}.rxdata")
  54.      @sprite.visible = true
  55.      if FileTest.exist?(DIR+"Save#{@index}.jpg")
  56.        @sprite.bitmap = Bitmap.new(DIR+"Save#{@index}.jpg")
  57.      else
  58.        self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?")
  59.      end
  60.      @sprite.x = 290
  61.      @sprite.y = 96
  62.      @sprite.z = 998
  63.      @sprite.zoom_x = 0.5
  64.      @sprite.zoom_y = 0.5
  65.      file = File.open(DIR+"Save#{@index}.rxdata", "r")
  66.      @time_stamp = file.mtime
  67.      @characters = Marshal.load(file)
  68.      @frame_count = Marshal.load(file)
  69.      @game_system = Marshal.load(file)
  70.      @game_switches = Marshal.load(file)
  71.      @game_variables = Marshal.load(file)
  72.      @total_sec = @frame_count / Graphics.frame_rate
  73.      file.close
  74.      for i in [email]0...@characters.size[/email]
  75.        @sp_ch[i] = Sprite.new
  76.        @sp_ch[i].visible = true
  77.        testname = @characters[i][2].name+"_f"
  78.        @sp_ch[i].bitmap = Bitmap.new("Graphics/battlers/#{testname}")
  79.        @sp_ch[i].zoom_x = 0.8
  80.        @sp_ch[i].zoom_y = 0.8
  81.        @sp_ch[i].x = 180        
  82.        @sp_ch[i].y = 96 + i*90
  83.        @sp_ch[i].z = 101
  84.      end
  85.      # 描绘游戏时间
  86.      hour = @total_sec / 60 / 60
  87.      min = @total_sec / 60 % 60
  88.      sec = @total_sec % 60
  89.      time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  90.      self.contents.font.color = normal_color
  91.      self.contents.draw_text(4, 326, 420, 32, time_string, 2)
  92.      # 描绘时间标记
  93.      self.contents.font.color = normal_color
  94.      time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  95.      self.contents.draw_text(4, 356, 420, 32, time_string, 2)
  96.    else
  97.      self.contents.draw_text(32,32,420,32,"这个存档是空的")
  98.    end
  99.  
  100. end
  101. def dispose
  102.    super
  103.    @sprite.dispose
  104.    @backsp.dispose
  105.    for i in @sp_ch
  106.      i.dispose
  107.    end
  108. end
  109. end
  110.  
  111.  
  112. class Window_File2 < Window_Base
  113. attr_accessor :index
  114. def initialize(index = 0)
  115.    @backsp = Sprite.new
  116.   # @backsp.bitmap = Bitmap.new("Graphics/Pictures/菜单底图.jpg")
  117.    @backsp.z = 100
  118.    super(160,0,480,480)
  119.    #这行可以不用
  120.    self.contents = Bitmap.new(width - 32, height - 32)
  121.    @index = index
  122.    #这里我要说明一句,之所以用sprite是为了放缩图片
  123.    @sprite = Sprite.new
  124.    @sprite.visible = false
  125.    @sprite.z = 100
  126.    @sp_ch = []
  127.    @sp_ch[0] = Sprite.new
  128.    refresh
  129. end
  130. def refresh
  131.    self.contents.clear
  132.    for i in @sp_ch
  133.      i.visible = false
  134.    end
  135.    @sprite.visible = false
  136.    if FileTest.exist?(DIR+"Save#{@index}.rxdata")
  137.      @sprite.visible = true
  138.      if FileTest.exist?(DIR+"Save#{@index}.jpg")
  139.        @sprite.bitmap = Bitmap.new(DIR+"Save#{@index}.jpg")
  140.      else
  141.        self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?")
  142.      end
  143.      @sprite.x = 290
  144.      @sprite.y = 32
  145.      @sprite.z = 998
  146.      @sprite.zoom_x = 0.5
  147.      @sprite.zoom_y = 0.5
  148.      file = File.open(DIR+"Save#{@index}.rxdata", "r")
  149.      @time_stamp = file.mtime
  150.      @characters = Marshal.load(file)
  151.      @frame_count = Marshal.load(file)
  152.      @game_system = Marshal.load(file)
  153.      @game_switches = Marshal.load(file)
  154.      @game_variables = Marshal.load(file)
  155.      @total_sec = @frame_count / Graphics.frame_rate
  156.      file.close
  157.      for i in [email]0...@characters.size[/email]
  158.        @sp_ch[i] = Sprite.new
  159.        @sp_ch[i].visible = true
  160.        testname = @characters[i][2].name+"_f" #修改
  161.        @sp_ch[i].bitmap = Bitmap.new("Graphics/battlers/#{testname}")
  162.        @sp_ch[i].x = 180        
  163.        @sp_ch[i].y = 24 + i*110
  164.        @sp_ch[i].z = 101
  165.      end
  166.      # 描绘游戏时间
  167.      hour = @total_sec / 60 / 60
  168.      min = @total_sec / 60 % 60
  169.      sec = @total_sec % 60
  170.      time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  171.      self.contents.font.color = normal_color
  172.      self.contents.draw_text(4, 390, 420, 32, time_string, 2)
  173.      # 描绘时间标记
  174.      self.contents.font.color = normal_color
  175.      time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  176.      self.contents.draw_text(4, 420, 420, 32, time_string, 2)
  177.    else
  178.      self.contents.draw_text(32,32,420,32,"这个存档是空的")
  179.    end
  180.  
  181. end
  182. def dispose
  183.    super
  184.    @sprite.dispose
  185.    @backsp.dispose
  186.    for i in @sp_ch
  187.      i.dispose
  188.    end
  189. end
  190. end
  191.  
  192.  
  193.  
  194. $打开自动存档用的开关编号 = 999
  195. $自动存档位置 = 1
  196. $按下F5之后的自动存档的音效 = "Audio/SE/系统存档"
  197. $按下F5之后禁止存档时候的音效 = "Audio/Se/系统错误"
  198. DIR = "Save/"
  199. $打开自动存档开关之后调用的公共事件 = 0 #——默认未定义
  200. $按下F5之后可以存档调用的公共事件 = 0 #——默认未定义
  201. $按下F5之后禁止存档调用的公共事件 = 0 #——默认未定义
  202. class Scene_Map
  203. alias auto_update update
  204. def update
  205. auto_update
  206. #——按下F5的时候自动存档,可以修改为F5,F6,F7,F8,也可以修改成默认按键但是不推荐。
  207. #——注意在不可存档的时候是无效的
  208. if Input.trigger?(Input::F5)
  209.   unless $game_system.map_interpreter.running?
  210.   if $game_system.save_disabled
  211.     Audio.se_play($按下F5之后禁止存档时候的音效)
  212.     $game_temp.common_event_id = $按下F5之后禁止存档调用的公共事件
  213.   else
  214.     Audio.se_play($按下F5之后的自动存档的音效)
  215.     $game_temp.common_event_id = $按下F5之后可以存档调用的公共事件
  216.     auto_save
  217.   end
  218.   end
  219. end
  220. #——当BOSS战之前打开一下定义的开关,即可自动存档
  221. if $game_switches[$打开自动存档用的开关编号] == true
  222.   $game_switches[$打开自动存档用的开关编号] = false
  223.   $game_temp.common_event_id = $打开自动存档开关之后调用的公共事件
  224.   auto_save
  225. end
  226. end
  227. def auto_save
  228. #——这里定义了储存的文件,如果不希望用Save4可以自己修改编号
  229. # 写入存档数据
  230. Screen::shot
  231.     file = File.open( DIR+"Save#{$自动存档位置}.rxdata", "wb")
  232.     auto_save_data(file)
  233.     if FileTest.exist?( DIR+"shot.jpg")
  234.       File.rename( DIR+"shot.jpg", DIR+"Save#{$自动存档位置}.jpg")
  235.     end
  236.     file.close
  237. end
  238. def auto_save_data(file)
  239. #——以下定义内容和Scene_Save的write_save_data(file)完全一样
  240. #——如果你修改过该存档方法,不要忘记用你修改的覆盖这部分内容。
  241. # 生成描绘存档文件用的角色图形
  242. characters = []
  243. for i in 0...$game_party.actors.size
  244.   actor = $game_party.actors[i]
  245.   characters.push([actor.character_name, actor.character_hue, actor])
  246. end
  247. # 写入描绘存档文件用的角色数据
  248. Marshal.dump(characters, file)
  249. # 写入测量游戏时间用画面计数
  250. Marshal.dump(Graphics.frame_count, file)
  251. # 增加 1 次存档次数
  252. $game_system.save_count += 1
  253. # 保存魔法编号
  254. # (将编辑器保存的值以随机值替换)
  255. $game_system.magic_number = $data_system.magic_number
  256. # 写入各种游戏对像
  257. Marshal.dump($game_system, file)
  258. Marshal.dump($game_switches, file)
  259. Marshal.dump($game_variables, file)
  260. Marshal.dump($game_self_switches, file)
  261. Marshal.dump($game_screen, file)
  262. Marshal.dump($game_actors, file)
  263. Marshal.dump($game_party, file)
  264. Marshal.dump($game_troop, file)
  265. Marshal.dump($game_map, file)
  266. Marshal.dump($game_player, file)
  267. end
  268. end
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276. DIR = "Save/"  # 储存文件夹名,请制作游戏时自行建立此文件夹
  277.  
  278.  
  279. module Screen  
  280. @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  281. @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l
  282.  
  283. p), 'l'
  284. @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  285. module_function
  286. def shot(file = "shot", typ = 1)
  287.    # to add the right extension...
  288.    if typ == 0
  289.      typname = ".bmp"
  290.    elsif typ == 1
  291.      typname = ".jpg"
  292.    elsif typ == 2
  293.      typname = ".png"
  294.    end   
  295.    file_index = 0   
  296.    dir = "Save/"   
  297.    # make the filename....
  298.    file_name = dir + file.to_s + typname.to_s   
  299.    # make the screenshot.... Attention dont change anything from here on....
  300.    @screen.call(0,0,640,480,file_name,handel,typ)
  301. end
  302. # find the game window...
  303. def handel
  304.    game_name = "\0" * 256
  305.    @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  306.    game_name.delete!("\0")
  307.    return @findwindow.call('RGSS Player',game_name)
  308. end
  309. end
  310.  
  311.  
  312. class Scene_Menu
  313. alias shotsave_main main
  314. def main
  315.    if @menu_index == 0
  316.      Screen::shot
  317.    end   
  318.    shotsave_main
  319. end
  320. end
  321.  
  322. class Interpreter
  323. #--------------------------------------------------------------------------
  324. # ● 调用存档画面
  325. #--------------------------------------------------------------------------
  326. def command_352
  327.    # 设置战斗中断标志
  328.    $game_temp.battle_abort = true
  329.    # 设置调用存档标志
  330.    $game_temp.save_calling = true
  331.    # 推进索引
  332.    @index += 1
  333.    # 结束
  334.    Screen::shot
  335.    return false
  336. end
  337. end
  338.  
  339. #==============================================================================
  340. # ■ Scene_Load
  341. #------------------------------------------------------------------------------
  342. #  处理读档画面的类。
  343. #==============================================================================
  344.  
  345. class Scene_Load
  346. #--------------------------------------------------------------------------
  347. # ● 初始化对像
  348. #--------------------------------------------------------------------------
  349. def initialize
  350.    # 再生成临时对像
  351.    $game_temp = Game_Temp.new
  352.    # 选择存档时间最新的文件
  353.    $game_temp.last_file_index = 0
  354.    latest_time = Time.at(0)
  355.    for i in 0..51
  356.      filename = DIR+"Save#{i}.rxdata"
  357.      if FileTest.exist?(filename)
  358.        file = File.open(filename, "r")
  359.        if file.mtime > latest_time
  360.          latest_time = file.mtime
  361.          $game_temp.last_file_index = i
  362.        end
  363.        file.close
  364.      end
  365.    end
  366. end  
  367. def main
  368.    @command_window = Window_Command.new(160,["自动存档","快速存档","进度二",
  369.    "进度三","进度四","进度五","进度六","进度七","进度八","进度九","进度十",
  370.    "进度十一","进度十二","进度十三","进度十四","进度十五","进度十六",
  371.    "进度十七","进度十八","进度十九","进度二十","进度二一","进度二二",
  372.    "进度二三","进度二四","进度二五","进度二六","进度二七","进度二八",
  373.    "进度二九","进度三十"])
  374.    @command_window.y = 0
  375.    @command_window.height = 480
  376.    @command_window.index = $game_temp.last_file_index
  377.    @content_window = Window_File2.new($game_temp.last_file_index)
  378.    # 执行过渡
  379.    Graphics.transition
  380.    # 主循环
  381.    loop do
  382.      # 刷新游戏画面
  383.      Graphics.update
  384.      # 刷新输入信息
  385.      Input.update
  386.      # 刷新画面
  387.      update
  388.      # 如果画面被切换的话就中断循环
  389.      if $scene != self
  390.        break
  391.      end
  392.    end
  393.    # 准备过渡
  394.    Graphics.freeze
  395.    @command_window.dispose
  396.    @content_window.dispose
  397. end
  398. def update
  399.    @command_window.update
  400.    if @command_window.index != @content_window.index
  401.      @content_window.index = @command_window.index
  402.      @content_window.refresh
  403.    end   
  404.    #——————下面这一部分是原装脚本——————#
  405.    if Input.trigger?(Input::B)  
  406.    # 演奏取消 SE
  407.    $game_system.se_play($data_system.cancel_se)
  408.    # 切换到标题画面
  409.    $scene = Scene_Title.new
  410.    end   
  411.    #———————————————————————#   
  412.    if Input.trigger?(Input::C)
  413.      # 文件不存在的情况下
  414.      unless FileTest.exist?(DIR+"Save#{@command_window.index}.rxdata")
  415.        # 演奏冻结 SE
  416.        $game_system.se_play($data_system.buzzer_se)
  417.        return
  418.      end
  419.      # 演奏读档 SE
  420.      $game_system.se_play($data_system.load_se)
  421.      # 写入存档数据
  422.      file = File.open(DIR+"Save#{@command_window.index}.rxdata",
  423.  
  424. "rb")
  425.      read_save_data(file)
  426.      file.close
  427.      # 还原 BGM、BGS
  428.      $game_system.bgm_play($game_system.playing_bgm)
  429.      $game_system.bgs_play($game_system.playing_bgs)
  430.      # 刷新地图 (执行并行事件)
  431.      $game_map.update
  432.      # 切换到地图画面
  433.      $scene = Scene_Map.new
  434.    end
  435.    #———————————————————————#
  436. end
  437. #--------------------------------------------------------------------------
  438. # ● 写入存档数据
  439. #     file : 写入用文件对像 (已经打开)
  440. #--------------------------------------------------------------------------
  441. def read_save_data(file)
  442.    # 读取描绘存档文件用的角色数据
  443.    characters = Marshal.load(file)
  444.    # 读取测量游戏时间用画面计数
  445.    Graphics.frame_count = Marshal.load(file)
  446.    # 读取各种游戏对像
  447.    $game_system        = Marshal.load(file)
  448.    $game_switches      = Marshal.load(file)
  449.    $game_variables     = Marshal.load(file)
  450.    $game_self_switches = Marshal.load(file)
  451.    $game_screen        = Marshal.load(file)
  452.    $game_actors        = Marshal.load(file)
  453.    $game_party         = Marshal.load(file)
  454.    $game_troop         = Marshal.load(file)
  455.    $game_map           = Marshal.load(file)
  456.    $game_player        = Marshal.load(file)
  457.    # 魔法编号与保存时有差异的情况下
  458.    # (加入编辑器的编辑过的数据)
  459.    if $game_system.magic_number != $data_system.magic_number
  460.      # 重新装载地图
  461.      $game_map.setup($game_map.map_id)
  462.      $game_player.center($game_player.x, $game_player.y)
  463.    end
  464.    # 刷新同伴成员
  465.    $game_party.refresh
  466. end
  467. end
  468.  
  469. #==============================================================================
  470. #  Window_LoadCommand
  471. #------------------------------------------------------------------------------
  472. #  存取档画面选择按钮窗口
  473. #==============================================================================
  474.  
  475. class Window_LoadCommand < Window_Selectable
  476. #--------------------------------------------------------------------------
  477. #  初始化对象
  478. #--------------------------------------------------------------------------
  479. def initialize
  480. super(320, 0, 320, 64)
  481. self.contents = Bitmap.new(width - 32, height - 32)
  482. self.contents.font.color = normal_color
  483. @item_max = 2
  484. @column_max = 2
  485. @commands = ["读取", "存储"]
  486. refresh
  487. self.index = 0
  488. end
  489. #--------------------------------------------------------------------------
  490. #  刷新
  491. #--------------------------------------------------------------------------
  492. def refresh
  493. self.contents.clear
  494. for i in 0...@item_max
  495.    draw_item(i)
  496. end
  497. end
  498. #--------------------------------------------------------------------------
  499. #  描画按钮文字
  500. #--------------------------------------------------------------------------
  501. def draw_item(index)
  502. x = 4 + index * 160
  503. self.contents.draw_text(x, 0, 144, 32, @commands[index])
  504. end
  505. #--------------------------------------------------------------------------
  506. # ● 项目无效化
  507. #     index : 项目编号
  508. #--------------------------------------------------------------------------
  509. def disable_item(index)
  510.    draw_item(index, disabled_color)
  511. end
  512.  
  513. end
  514.  
  515. #==============================================================================
  516. #  Scene_Loadsave
  517. #------------------------------------------------------------------------------
  518. # 处理存取档画面的类。
  519. #==============================================================================
  520.  
  521. class Scene_Loadsave
  522. #--------------------------------------------------------------------------
  523. # ● 初始化对像
  524. #     $last_savefile_index : 记录光标位置
  525. #--------------------------------------------------------------------------
  526. def initialize
  527.    $last_savefile_index = 0 if $last_savefile_index == nil
  528.    # 再生成临时对像
  529.    $game_temp = Game_Temp.new
  530.    # 选择存档时间最新的文件
  531.    $game_temp.last_file_index = 0
  532.    latest_time = Time.at(0)
  533.    for i in 0..51
  534.      filename =  DIR+"Save#{i}.rxdata"
  535.      if FileTest.exist?(filename)
  536.        file = File.open(filename, "r")
  537.        if file.mtime > latest_time
  538.          latest_time = file.mtime
  539.          $game_temp.last_file_index = i
  540.        end
  541.        file.close
  542.      end
  543.    end
  544. end
  545. #--------------------------------------------------------------------------
  546. #  主处理
  547. #--------------------------------------------------------------------------
  548. def main         
  549.  
  550.    @savestate = 0
  551.    # 生成窗口
  552.    @help_window = Window_LoadHelp.new
  553.    @help_window.set_text("请选择.")
  554.    @option_window = Window_LoadCommand.new
  555.    @option_window.index = $last_savefile_index
  556.    ########################################################
  557.    @command_window = Window_Command.new(160,["自动存档","快速存档","进度二",
  558.      "进度三","进度四","进度五","进度六","进度七","进度八","进度九","进度十",
  559.      "进度十一","进度十二","进度十三","进度十四","进度十五","进度十六",
  560.      "进度十七","进度十八","进度十九","进度二十","进度二一","进度二二",
  561.      "进度二三","进度二四","进度二五","进度二六","进度二七","进度二八",
  562.      "进度二九","进度三十"])
  563.      @command_window.y = 64
  564.      @command_window.height = 416
  565.      @command_window.index = $game_temp.last_file_index
  566.      @content_window = Window_File.new($game_temp.last_file_index)
  567.      @command_window.active = false
  568.        ###############覆盖存档
  569.        @confirm_window = Window_Base.new(120, 188, 400, 64)
  570.        @confirm_window.contents = Bitmap.new(368, 32)
  571.  
  572.        @confirm_window.contents.font.color = Color.new(255,255,255,255)
  573.  
  574.        string = "确定要覆盖这个进度吗?"
  575.        @confirm_window.contents.font.name = "黑体"
  576.        @confirm_window.contents.font.size = 24
  577.        @confirm_window.contents.draw_text(4, 0, 368, 32, string)
  578.        @yes_no_window = Window_Command.new(100, ["覆盖", "取消"])
  579.        @confirm_window.z = 1500
  580.        @yes_no_window.index = 1
  581.        @yes_no_window.x = 270
  582.        @yes_no_window.y = 252
  583.        @yes_no_window.z = 1500
  584.        @confirm_window.visible = false
  585.        @yes_no_window.visible = false
  586.        @yes_no_window.active = false
  587.  
  588.    # 执行过渡
  589.    Graphics.transition
  590.    # 主循环
  591.    loop do
  592.      # 刷新游戏画面
  593.      Graphics.update
  594.      # 刷新输入信息
  595.      Input.update
  596.      # 刷新画面
  597.      update
  598.      # 如果画面被切换的话就中断循环
  599.      if $scene != self
  600.        break
  601.      end
  602.    end
  603.    # 准备过渡
  604.    Graphics.freeze
  605.    # 释放窗口
  606.    @command_window.dispose
  607.    @content_window.dispose
  608.    @confirm_window.dispose
  609.    @yes_no_window.dispose
  610.    @help_window.dispose
  611.    @option_window.dispose
  612. end
  613.  
  614. #--------------------------------------------------------------------------
  615. #  ● 刷新画面
  616. #--------------------------------------------------------------------------
  617. def update
  618.    # 刷新窗口
  619.    @help_window.update
  620.    @option_window.update
  621. #   @content_window.update
  622.    @command_window.update
  623.    if @yes_no_window.active
  624.        confirm_update
  625.        return
  626.    end
  627.    @content_window.index = @command_window.index
  628.    @content_window.refresh
  629.    case @savestate
  630.    when 0
  631.        if Input.trigger?(Input::B)
  632.        $game_system.se_play($data_system.cancel_se)
  633.        # 返回地图
  634.        if $menu_call == false
  635.        # 切换到地图画面
  636.        $scene = Scene_Map.new
  637.          return
  638.        end
  639.        # 切换到菜单画面
  640.        $menu_call = false
  641.        $scene = Scene_Menu.new(4)
  642.     end
  643.      if Input.trigger?(Input::C)
  644.        case @option_window.index
  645.        when 0
  646.          @command_window.active = true
  647.          @option_window.active = false
  648.          $game_system.se_play($data_system.decision_se)
  649.          @help_window.set_text("请选择一个文件进行读取.")
  650.          @savestate  = 1
  651.          return
  652.        when 1
  653.          @command_window.active = true
  654.          @option_window.active = false
  655.          $game_system.se_play($data_system.decision_se)
  656.          @help_window.set_text("请选择一个文件进行存储.")
  657.          @savestate = 2
  658.  
  659.          return
  660.        return
  661.        end
  662.      end
  663.    when 1,2
  664.      if Input.trigger?(Input::C)
  665.        if @savestate == 1
  666.          $menu_call = false
  667.          load_file
  668.          return
  669.        else
  670.          # 禁止存档的情况下
  671.          if $game_system.save_disabled
  672.            @help_window.set_text("抱歉,这里禁止存储.")
  673.            # 演奏冻结 SE
  674.            $game_system.se_play($data_system.buzzer_se)
  675.            return
  676.          end
  677.         $game_system.se_play($data_system.decision_se)
  678.         $last_savefile_index = @option_window.index
  679.  
  680.         save_file
  681.          return
  682.        end
  683.      end
  684.      # 取消
  685.      if Input.trigger?(Input::B)
  686.        $game_system.se_play($data_system.cancel_se)
  687.        @command_window.active = false
  688.        @help_window.set_text("请选择.")
  689.        @savestate = 0
  690.        @option_window.active = true
  691.        return
  692.      end
  693.  
  694.      if Input.trigger?(Input::B)
  695.        $game_system.se_play($data_system.cancel_se)
  696.        @savestate = 2
  697.        @command_window.active = true
  698.  
  699.        return
  700.      end
  701.    end
  702. end
  703. #--------------------------------------------------------------------------
  704. # 建立记录文件索引
  705. #--------------------------------------------------------------------------
  706.  
  707. #--------------------------------------------------------------------------
  708. #  读取记录文件
  709. #     filename  : 被读取文件
  710. #--------------------------------------------------------------------------
  711. def load_file
  712.      # 文件不存在的情况下
  713.      unless FileTest.exist?( DIR+"Save#{@command_window.index}.rxdata")
  714.        # 演奏冻结 SE
  715.        $game_system.se_play($data_system.buzzer_se)
  716.        return
  717.      end
  718.      # 演奏读档 SE
  719.      $game_system.se_play($data_system.load_se)
  720.      # 写入存档数据
  721.      file = File.open( DIR+"Save#{@command_window.index}.rxdata", "rb")
  722.      read_save_data(file)
  723.      file.close
  724.      # 还原 BGM、BGS
  725.      $game_system.bgm_play($game_system.playing_bgm)
  726.      $game_system.bgs_play($game_system.playing_bgs)
  727.      # 刷新地图 (执行并行事件)
  728.      $game_map.update
  729.      # 切换到地图画面
  730.      $scene = Scene_Map.new
  731. end
  732. #--------------------------------------------------------------------------
  733. # ● 读取存档数据
  734. #     file : 读取用文件对像 (已经打开)
  735. #--------------------------------------------------------------------------
  736. def read_save_data(file)
  737.    # 读取描绘存档文件用的角色数据
  738.    characters = Marshal.load(file)
  739.    # 读取测量游戏时间用画面计数
  740.    Graphics.frame_count = Marshal.load(file)
  741.    # 读取各种游戏对像
  742.    $game_system        = Marshal.load(file)
  743.    $game_switches      = Marshal.load(file)
  744.    $game_variables     = Marshal.load(file)
  745.    $game_self_switches = Marshal.load(file)
  746.    $game_screen        = Marshal.load(file)
  747.    $game_actors        = Marshal.load(file)
  748.    $game_party         = Marshal.load(file)
  749.    $game_troop         = Marshal.load(file)
  750.    $game_map           = Marshal.load(file)
  751.    $game_player        = Marshal.load(file)
  752.    # 魔法编号与保存时有差异的情况下
  753.    # (加入编辑器的编辑过的数据)
  754.    if $game_system.magic_number != $data_system.magic_number
  755.      # 重新装载地图
  756.      $game_map.setup($game_map.map_id)
  757.      $game_player.center($game_player.x, $game_player.y)
  758.    end
  759.    # 刷新同伴成员
  760.    $game_party.refresh
  761. end
  762. #--------------------------------------------------------------------------
  763. # ● 写入存档文件
  764. #--------------------------------------------------------------------------
  765. def save_file
  766.    if Input.trigger?(Input::C)
  767.      unless FileTest.exist?( DIR+"Save#{@command_window.index}.rxdata")
  768.        # 演奏冻结 SE
  769.        # 演奏存档 SE
  770.          $game_system.se_play($data_system.save_se)
  771.          # 写入存档数据
  772.          file = File.open( DIR+"Save#{@command_window.index}.rxdata", "wb")
  773.          write_save_data(file)
  774.          if FileTest.exist?( DIR+"shot.jpg")
  775.            File.rename( DIR+"shot.jpg",  DIR+"Save#{@command_window.index}.jpg")
  776.          end
  777.          file.close
  778.          $game_temp.last_file_index = @command_window.index
  779.          # 如果被事件调用
  780.          if $game_temp.save_calling
  781.            # 清除存档调用标志
  782.            $game_temp.save_calling = false
  783.            @confirm_window.dispose
  784.            # 切换到地图画面
  785.            $scene = Scene_Map.new   
  786.            return
  787.          end
  788.        # 切换到菜单画面
  789.          $scene = Scene_Map.new  
  790.      end
  791.      @yes_no_window.active = true
  792.      @command_window.active = false            
  793.    end
  794.    #———————————————————————#     
  795. end
  796. #-------------------------------------------------------------------
  797. def confirm_update
  798.    @command_index = @command_window.index
  799.    @confirm_window.visible = true
  800.    @confirm_window.z = 1500
  801.    @yes_no_window.visible = true
  802.    @yes_no_window.active = true
  803.    @yes_no_window.z = 1500
  804.    @yes_no_window.update
  805.    if Input.trigger?(Input::C)
  806.      if @yes_no_window.index == 0
  807.          #######################################################
  808.          # 演奏存档 SE
  809.          $game_system.se_play($data_system.save_se)
  810.          # 写入存档数据
  811.          file = File.open( DIR+"Save#{@command_window.index}.rxdata", "wb")
  812.          write_save_data(file)
  813.          if FileTest.exist?( DIR+"shot.jpg")
  814.            File.rename( DIR+"shot.jpg",  DIR+"Save#{@command_window.index}.jpg")
  815.          end
  816.          file.close
  817.          $game_temp.last_file_index = @command_window.index
  818.          # 如果被事件调用
  819.          if $game_temp.save_calling
  820.            # 清除存档调用标志
  821.            $game_temp.save_calling = false
  822.            @confirm_window.dispose
  823.            @content_window.dispose
  824.            # 切换到地图画面
  825.            $scene = Scene_Map.new
  826.  
  827.            return
  828.          end
  829.        # 切换到菜单画面
  830.          $scene = Scene_Map.new        
  831.        else
  832.        @yes_no_window.visible = false
  833.        @confirm_window.visible = false
  834.        $game_system.se_play($data_system.cancel_se)
  835.        @yes_no_window.active = false
  836.        @command_window.active = true
  837.        end
  838.    end
  839.    if Input.trigger?(Input::B)
  840.      @yes_no_window.visible = false
  841.      @confirm_window.visible = false
  842.      $game_system.se_play($data_system.cancel_se)
  843.      @yes_no_window.active = false
  844.      @command_window.active = true
  845.    end
  846. end
  847. #--------------------------------------------------------------------------
  848. # ● 写入存档数据
  849. #     file : 写入用文件对像 (已经打开)
  850. #--------------------------------------------------------------------------
  851. def write_save_data(file)
  852.    # 生成描绘存档文件用的角色图形
  853.    characters = []
  854.    for i in 0...$game_party.actors.size
  855.      actor = $game_party.actors[i]
  856.      characters.push([actor.character_name, actor.character_hue, actor])
  857.    end
  858.    # 写入描绘存档文件用的角色数据
  859.    Marshal.dump(characters, file)
  860.    # 写入测量游戏时间用画面计数
  861.    Marshal.dump(Graphics.frame_count, file)
  862.    # 增加 1 次存档次数
  863.    $game_system.save_count += 1
  864.    # 保存魔法编号
  865.    # (将编辑器保存的值以随机值替换)
  866.    $game_system.magic_number = $data_system.magic_number
  867.    # 写入各种游戏对像
  868.    Marshal.dump($game_system, file)
  869.    Marshal.dump($game_switches, file)
  870.    Marshal.dump($game_variables, file)
  871.    Marshal.dump($game_self_switches, file)
  872.    Marshal.dump($game_screen, file)
  873.    Marshal.dump($game_actors, file)
  874.    Marshal.dump($game_party, file)
  875.    Marshal.dump($game_troop, file)
  876.    Marshal.dump($game_map, file)
  877.    Marshal.dump($game_player, file)
  878. end
  879. end
  880.  
  881. #==============================================================================
  882. # ■ Window_LoadHelp
  883. #------------------------------------------------------------------------------
  884. #  存取档画面帮助信息的显示窗口。
  885. #==============================================================================
  886.  
  887. class Window_LoadHelp < Window_Base
  888. #--------------------------------------------------------------------------
  889. #  初始化对象
  890. #--------------------------------------------------------------------------
  891. def initialize
  892. super(0, 0, 320, 64)
  893. self.contents = Bitmap.new(width - 32, height - 32)
  894. end
  895. #--------------------------------------------------------------------------
  896. #  刷新文本
  897. #--------------------------------------------------------------------------
  898. def set_text(text, align = 1)
  899. if text != @text or align != @align
  900.    self.contents.clear
  901.    self.contents.font.color = normal_color
  902.    self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
  903.    @text = text
  904.    @align = align
  905.    @actor = nil
  906. end
  907. self.visible = true
  908. end
  909. end

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
2
发表于 2012-8-18 14:51:10 | 只看该作者
找到77-78行
  1.        testname = @characters[i][2].name+"_f"
  2.        @sp_ch[i].bitmap = Bitmap.new("Graphics/battlers/#{testname}")
复制代码
改成
  1.        @sp_ch[i].bitmap = Bitmap.new("Graphics/battlers/#{@character[i][2].actor_id}_f")
复制代码
这样一号角色的存档头像为1_f.*

未经测试

http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
381 小时
注册时间
2012-8-13
帖子
113
3
 楼主| 发表于 2012-8-18 16:06:08 | 只看该作者
本帖最后由 tyq4590 于 2012-8-18 20:07 编辑
Wind2010 发表于 2012-8-18 18:51
找到77-78行改成这样一号角色的存档头像为1_f.*

未经测试


试了一下你提供的代码 但是提示找不到图片 所以估计调用没成功 但不知道为什么我试了一下把这个值从变量设置成固定图片也不行:

RUBY 代码复制
  1. testname = "1_f"
  2.        @sp_ch[i].bitmap = Bitmap.new("Graphics/battlers/#{testname}")


结果运行的时候还是会出错(还是提示找不到'新角色名_f.png') 也试了改成:

RUBY 代码复制
  1. @sp_ch[i].bitmap = Bitmap.new("Graphics/battlers/1_f")


这样也不行 (还是提示找不到'新角色名_f.png')
回复 支持 反对

使用道具 举报

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
4
发表于 2012-8-18 17:29:17 | 只看该作者
你P一下@character[i][2].actor_id,或者是2号队员之类的问题……

评分

参与人数 1星屑 +200 梦石 +2 收起 理由
hcm + 200 + 2 认可答案

查看全部评分


http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
381 小时
注册时间
2012-8-13
帖子
113
5
 楼主| 发表于 2012-8-18 23:57:40 | 只看该作者
已解决 谢了!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 20:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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