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

Project1

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

怎么往这个菜单里添加存档的功能

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
29 小时
注册时间
2008-4-13
帖子
771
跳转到指定楼层
1
发表于 2008-6-9 01:27:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
http://rpg.blue/web/htm/news460.htm
这个里面的菜单我感觉不错。问题是怎么往里面添加存档啊?
版务信息:本贴由楼主自主结贴~
我,南歌,回6R啦!

Lv1.梦旅人

梦石
0
星屑
50
在线时间
27 小时
注册时间
2008-2-13
帖子
1740
2
发表于 2008-6-9 01:33:56 | 只看该作者
  1. #==============================================================================
  2. # ■ Scene_Save
  3. #------------------------------------------------------------------------------
  4. #  处理存档画面的类。
  5. #==============================================================================

  6. class Scene_Save < Scene_File
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super("要保存到这个文件吗?")
  12.   end
  13.   #--------------------------------------------------------------------------
  14.   # ● 确定时的处理
  15.   #--------------------------------------------------------------------------
  16.   def on_decision(filename)
  17.     # 演奏存档 SE
  18.     $game_system.se_play($data_system.save_se)
  19.     # 写入存档数据
  20.     file = File.open(filename, "wb")
  21.     write_save_data(file)
  22.     file.close
  23.     # 如果被事件调用
  24.     if $game_temp.save_calling
  25.       # 清除存档调用标志
  26.       $game_temp.save_calling = false
  27.       # 切换到地图画面
  28.       $scene = Scene_Map.new
  29.       return
  30.     end
  31.     # 切换到菜单画面
  32.     $scene = Scene_Menu.new(7)
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 取消时的处理
  36.   #--------------------------------------------------------------------------
  37.   def on_cancel
  38.     # 演奏取消 SE
  39.     $game_system.se_play($data_system.cancel_se)
  40.     # 如果被事件调用
  41.     if $game_temp.save_calling
  42.       # 清除存档调用标志
  43.       $game_temp.save_calling = false
  44.       # 切换到地图画面
  45.       $scene = Scene_Map.new
  46.       return
  47.     end
  48.     # 切换到菜单画面
  49.     $scene = Scene_Menu.new(7)
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● 写入存档数据
  53.   #     file : 写入用文件对像 (已经打开)
  54.   #--------------------------------------------------------------------------
  55.   def write_save_data(file)
  56.     # 生成描绘存档文件用的角色图形
  57.     characters = []
  58.     for i in 0...$game_party.actors.size
  59.       actor = $game_party.actors[i]
  60.       characters.push([actor.character_name, actor.character_hue])
  61.     end
  62.     # 写入描绘存档文件用的角色数据
  63.     Marshal.dump(characters, file)
  64.     # 写入测量游戏时间用画面计数
  65.     Marshal.dump(Graphics.frame_count, file)
  66.     # 增加 1 次存档次数
  67.     $game_system.save_count += 1
  68.     # 保存魔法编号
  69.     # (将编辑器保存的值以随机值替换)
  70.     $game_system.magic_number = $data_system.magic_number
  71.     # 写入各种游戏对像
  72.     Marshal.dump($game_system, file)
  73.     Marshal.dump($game_switches, file)
  74.     Marshal.dump($game_variables, file)
  75.     Marshal.dump($game_self_switches, file)
  76.     Marshal.dump($game_screen, file)
  77.     Marshal.dump($game_actors, file)
  78.     Marshal.dump($game_party, file)
  79.     Marshal.dump($game_troop, file)
  80.     Marshal.dump($game_map, file)
  81.     Marshal.dump($game_player, file)
  82.   end
  83. end


  84. class Window_Command_New < Window_Selectable
  85.   def initialize(actors=4,enemynums=0)
  86.     super(438, 20, 172, 160)
  87.     self.contents = Bitmap.new(width - 32, height - 32)
  88.     self.opacity = HS::OPACITY
  89.     @commands = ["战斗","物品","魔法","状态","装备","队列","任务","存档"]
  90.     @item_max = 8
  91.     @column_max = 2
  92.     @actors = actors
  93.     @enemynums = enemynums
  94.     draw_item(0, @enemynums==0 ? disabled_color : normal_color)
  95.     draw_item(1, normal_color)
  96.     draw_item(2, @actors==0 ? disabled_color : normal_color)
  97.     draw_item(3, @actors==0 ? disabled_color : normal_color)
  98.     draw_item(4, @actors==0 ? disabled_color : normal_color)
  99.     draw_item(5, @actors==0 ? disabled_color : normal_color)
  100.     draw_item(6, normal_color)
  101.     draw_item(7, normal_color)
  102.     self.index = 0
  103.   end
  104.   def draw_item(index, color)
  105.     self.contents.font.color = color
  106.     x = 4 + index % 2 * 70
  107.     y = index / 2 * 32
  108.     rect = Rect.new(x, y, 64, 32)
  109.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  110.     self.contents.draw_text(rect, @commands[index], 1)
  111.   end
  112.   def update_cursor_rect
  113.     x = 4 + index % 2 * 70
  114.     y = index / 2 * 32
  115.     self.cursor_rect.set(x, y, 64, 32)
  116.   end
  117. end

  118. class Scene_Menu
  119.   def initialize(menu_index = 0)
  120.     @menu_index = menu_index
  121.   end
  122.   def main
  123. #   check_enemy_in_map($game_player.x,$game_player.y)
  124.     cmd = Window_Command_New.new($game_party.actors.size)
  125.     cmd.index = @menu_index
  126.     Graphics.transition
  127.     loop do
  128.       Graphics.update
  129.       Input.update
  130.       cmd.update
  131.       if Input.trigger?(Input::B)
  132.         $game_system.se_play($data_system.cancel_se)
  133.         $scene = Scene_Map.new
  134.       end
  135.       if Input.trigger?(Input::C)
  136.         case cmd.index
  137.         when 0
  138.           $game_system.se_play($data_system.buzzer_se)
  139.         when 1
  140.           $game_system.se_play($data_system.decision_se)
  141.           $scene = Scene_Item.new
  142.         when 2
  143.           $game_system.se_play($data_system.decision_se)
  144.           $scene = Scene_Skill.new
  145.         when 3
  146.           $game_system.se_play($data_system.decision_se)
  147.           $scene = Scene_Status.new
  148.         when 4
  149.           $game_system.se_play($data_system.decision_se)
  150.           $scene = Scene_Equip.new
  151.         when 5
  152.           $game_system.se_play($data_system.decision_se)
  153.           $scene = Scene_Change_Turn.new
  154.         when 6
  155.           print "可以自己结合叶子的任务系统设计"
  156.         when 7
  157.           $game_system.se_play($data_system.decision_se)
  158.           $scene=Scene_Save.new
  159.         end
  160.       end
  161.       if $scene != self
  162.         break
  163.       end
  164.     end
  165.     Graphics.freeze
  166.     cmd.dispose
  167.   end
  168. end

复制代码



插入到Main之前,少处修改{/gg}
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
好吧,果然换个签名就没人认识我了。我承认我被时间埋没了
回复 支持 反对

使用道具 举报

Lv2.观梦者

神隐的主犯

梦石
0
星屑
373
在线时间
271 小时
注册时间
2008-2-22
帖子
7691

贵宾

3
发表于 2008-6-9 01:36:01 | 只看该作者
菜单里的脚本 Scene_Menu , 第 8 行 :

@commands = ["战斗","物品","魔法","状态","装备","队列","任务","系统"]

系统换成 “存档”

就是 @commands = ["战斗","物品","魔法","状态","装备","队列","任务","存档"]





第 77 行 改成


  1. if $game_system.save_disabled
  2.   # 演奏冻结 SE
  3.   $game_system.se_play($data_system.buzzer_se)
  4.   return
  5. end
  6.   # 演奏确定 SE
  7.   $game_system.se_play($data_system.decision_se)
  8.   # 切换到存档画面
  9.   $scene = Scene_Save.new

复制代码


在Main之前增加这个:


  1. class Scene_Save < Scene_File
  2.   def on_cancel
  3.     # 演奏取消 SE
  4.     $game_system.se_play($data_system.cancel_se)
  5.     # 如果被事件调用
  6.     if $game_temp.save_calling
  7.       # 清除存档调用标志
  8.       $game_temp.save_calling = false
  9.       # 切换到地图画面
  10.       $scene = Scene_Map.new
  11.       return
  12.     end
  13.     # 切换到菜单画面
  14.     $scene = Scene_Menu.new(7)
  15.   end
  16. end
复制代码

《天空之城 —— 破碎的命运》
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
142
在线时间
264 小时
注册时间
2006-11-22
帖子
1057
4
发表于 2008-6-9 01:37:23 | 只看该作者
替换那脚本的Window_Command_New,havealook那个用了就不能用事件禁止存档,没了:
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
  1. class Window_Command_New < Window_Selectable
  2.   def initialize(actors=4,enemynums=0)
  3.     super(438, 20, 172, 160)
  4.     self.contents = Bitmap.new(width - 32, height - 32)
  5.     self.opacity = HS::OPACITY
  6.     @commands = ["战斗","物品","魔法","状态","装备","队列","任务","存档"]
  7.     @item_max = 8
  8.     @column_max = 2
  9.     @actors = actors
  10.     @enemynums = enemynums
  11.     draw_item(0, @enemynums==0 ? disabled_color : normal_color)
  12.     draw_item(1, normal_color)
  13.     draw_item(2, @actors==0 ? disabled_color : normal_color)
  14.     draw_item(3, @actors==0 ? disabled_color : normal_color)
  15.     draw_item(4, @actors==0 ? disabled_color : normal_color)
  16.     draw_item(5, @actors==0 ? disabled_color : normal_color)
  17.     draw_item(6, normal_color)
  18.     draw_item(7, normal_color)
  19.     self.index = 0
  20.   end
  21.   def draw_item(index, color)
  22.     self.contents.font.color = color
  23.     x = 4 + index % 2 * 70
  24.     y = index / 2 * 32
  25.     rect = Rect.new(x, y, 64, 32)
  26.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  27.     self.contents.draw_text(rect, @commands[index], 1)
  28.   end
  29.   def update_cursor_rect
  30.     x = 4 + index % 2 * 70
  31.     y = index / 2 * 32
  32.     self.cursor_rect.set(x, y, 64, 32)
  33.   end
  34. end

  35. class Scene_Menu
  36.   def initialize(menu_index = 0)
  37.     @menu_index = menu_index
  38.   end
  39.   def main
  40. #   check_enemy_in_map($game_player.x,$game_player.y)
  41.     cmd = Window_Command_New.new($game_party.actors.size)
  42.     cmd.index = @menu_index
  43.     Graphics.transition
  44.     loop do
  45.       Graphics.update
  46.       Input.update
  47.       cmd.update
  48.       if Input.trigger?(Input::B)
  49.         $game_system.se_play($data_system.cancel_se)
  50.         $scene = Scene_Map.new
  51.       end
  52.       if Input.trigger?(Input::C)
  53.         case cmd.index
  54.         when 0
  55.           $game_system.se_play($data_system.buzzer_se)
  56.         when 1
  57.           $game_system.se_play($data_system.decision_se)
  58.           $scene = Scene_Item.new
  59.         when 2
  60.           $game_system.se_play($data_system.decision_se)
  61.           $scene = Scene_Skill.new
  62.         when 3
  63.           $game_system.se_play($data_system.decision_se)
  64.           $scene = Scene_Status.new
  65.         when 4
  66.           $game_system.se_play($data_system.decision_se)
  67.           $scene = Scene_Equip.new
  68.         when 5
  69.           $game_system.se_play($data_system.decision_se)
  70.           $scene = Scene_Change_Turn.new
  71.         when 6
  72.           print "可以自己结合叶子的任务系统设计"
  73.         when 7
  74.           # 禁止存档的情况下
  75.         if $game_system.save_disabled
  76.           # 演奏冻结 SE
  77.           $game_system.se_play($data_system.buzzer_se)
  78.           return
  79.         end
  80.         # 演奏确定 SE
  81.         $game_system.se_play($data_system.decision_se)
  82.         # 切换到存档画面
  83.         $scene = Scene_Save.new
  84.         end
  85.       end
  86.       if $scene != self
  87.         break
  88.       end
  89.     end
  90.     Graphics.freeze
  91.     cmd.dispose
  92.   end
  93. end
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
29 小时
注册时间
2008-4-13
帖子
771
5
 楼主| 发表于 2008-6-9 01:37:51 | 只看该作者
试试看
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
27 小时
注册时间
2008-2-13
帖子
1740
6
发表于 2008-6-9 01:38:14 | 只看该作者
回八云紫,你考虑不周到哦{/gg}
如果按你说的,进入存档界面后,按ESC后,光标不会在“存档”上
还得修改Scene_Save返回后光标停留到第几项
这点我在2楼的脚本中修改了{/gg}
好吧,果然换个签名就没人认识我了。我承认我被时间埋没了
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-3-29
帖子
826
7
发表于 2008-6-9 01:38:49 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv2.观梦者

神隐的主犯

梦石
0
星屑
373
在线时间
271 小时
注册时间
2008-2-22
帖子
7691

贵宾

8
发表于 2008-6-9 01:39:17 | 只看该作者
以下引用havealook于2008-6-8 17:38:14的发言:

回八云紫,你考虑不周到哦
如果按你说的,进入存档界面后,按ESC后,光标不会在“存档”上
还得修改Scene_Save返回后光标停留到第几项
这点我在2楼的脚本中修改了


呵呵,忘记返回了。 明白了。

《天空之城 —— 破碎的命运》
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
27 小时
注册时间
2008-2-13
帖子
1740
9
发表于 2008-6-9 01:41:47 | 只看该作者
事件存档...
谁会考虑到那啊...{/gg}
好吧,果然换个签名就没人认识我了。我承认我被时间埋没了
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
29 小时
注册时间
2008-4-13
帖子
771
10
 楼主| 发表于 2008-6-9 01:41:50 | 只看该作者
怎么用了后就不透明了啊{/ll}
我,南歌,回6R啦!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-8-3 18:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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