Project1
标题:
请问如何一打开游戏就自动开始新游戏或读取存档,并且...
[打印本页]
作者:
qmario
时间:
2014-7-19 12:29
标题:
请问如何一打开游戏就自动开始新游戏或读取存档,并且...
并且存档时只能存一个?
作者:
kuerlulu
时间:
2014-7-19 12:38
Scene_Title第55~59行改为如下
if @continue_enabled
command_continue
else
command_new_game
end
复制代码
另外这样只是打开读档界面而已, 存档只能存一个要改Scene_Load了现在没空等大触来回答吧
作者:
恐惧剑刃
时间:
2014-7-19 12:38
本帖最后由 恐惧剑刃 于 2014-7-19 13:27 编辑
放在main前
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
# 处理标题画面的类。
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# ● 读取存档数据
# file : 读取用文件对像 (已经打开)
#--------------------------------------------------------------------------
def read_save_data(file)
# 读取描绘存档文件用的角色数据
characters = Marshal.load(file)
# 读取测量游戏时间用画面计数
Graphics.frame_count = Marshal.load(file)
# 读取各种游戏对像
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
# 魔法编号与保存时有差异的情况下
# (加入编辑器的编辑过的数据)
if $game_system.magic_number != $data_system.magic_number
# 重新装载地图
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
# 刷新同伴成员
$game_party.refresh
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 战斗测试的情况下
if $BTEST
battle_test
return
end
# 载入数据库
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
# 生成系统对像
$game_system = Game_System.new
if FileTest.exist?("Save.rxdata")
$game_temp = Game_Temp.new
# 演奏读档 SE
$game_system.se_play($data_system.load_se)
# 写入存档数据
file = File.open("Save.rxdata", "rb")
read_save_data(file)
file.close
# 还原 BGM、BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# 刷新地图 (执行并行事件)
$game_map.update
# 切换到地图画面
$scene = Scene_Map.new
return
else
command_new_game
return
end
# 生成标题图形
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
# 生成命令窗口
s1 = "新游戏"
s2 = "继续"
s3 = "退出"
@command_window = Window_Command.new(192, [s1, s2, s3])
@command_window.back_opacity = 160
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
# 继续为有效的情况下、光标停止在继续上
# 无效的情况下、继续的文字显示为灰色
if @continue_enabled
@command_window.index = 1
else
@command_window.disable_item(1)
end
# 演奏标题 BGM
$game_system.bgm_play($data_system.title_bgm)
# 停止演奏 ME、BGS
Audio.me_stop
Audio.bgs_stop
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换就中断循环
if $scene != self
break
end
end
# 装备过渡
Graphics.freeze
# 释放命令窗口
@command_window.dispose
# 释放标题图形
@sprite.bitmap.dispose
@sprite.dispose
end
end
#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
# 显示存档以及读档画面、保存文件的窗口。
#==============================================================================
class Window_SaveFile < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# file_index : 存档文件的索引 (0~3)
# filename : 文件名
#--------------------------------------------------------------------------
def initialize
super(0, 64*3, 640, 104)
self.contents = Bitmap.new(width - 32, height - 32)
@max_item = 1
@filename = "Save.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
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# 描绘文件编号
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 600, 32, "文件")
# 存档文件存在的情况下
if @file_exist
# 描绘角色
for i in
[email protected]
bitmap = RPG::Cache.character(@characters[i][0], @characters[i][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
# 描绘游戏时间
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
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(0, 0, contents.text_size("文件").width + 8, 32)
end
end
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
# 存档画面及读档画面的超级类。
#==============================================================================
class Scene_File
#--------------------------------------------------------------------------
# ● 初始化对像
# help_text : 帮助窗口显示的字符串
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口
@help_window = Window_Help.new
@help_window.y = 64*2
@help_window.set_text(@help_text)
# 生成存档文件窗口
@savefile_windows = Window_SaveFile.new
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@savefile_windows.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@savefile_windows.update
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 调用过程 on_decision (定义继承目标)
on_decision("Save.rxdata")
return
end
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 调用过程 on_cancel (定义继承目标)
on_cancel
return
end
end
end
#==============================================================================
# ■ Scene_Save
#------------------------------------------------------------------------------
# 处理存档画面的类。
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super("要保存文件吗?")
end
def main
map = Spriteset_Map.new
super
map.dispose
end
end
复制代码
作者:
qmario
时间:
2014-7-19 12:49
恐惧剑刃 发表于 2014-7-19 12:38
找到Scene_Title
默认32行一直到# 演奏标题 BGM中间删掉替换为只能帮你到这儿了。。。
好像不行
作者:
qmario
时间:
2014-7-19 12:52
恐惧剑刃 发表于 2014-7-19 12:38
找到Scene_Title
默认32行一直到# 演奏标题 BGM中间删掉替换为只能帮你到这儿了。。。
我是说,如果没有存档直接开始游戏,如果有存档就进那一个,存档时也只能存一个
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1