Project1
标题:
如何在存档和读档处显示头像
[打印本页]
作者:
步兵中尉
时间:
2011-2-12 15:16
标题:
如何在存档和读档处显示头像
本帖最后由 步兵中尉 于 2011-2-13 15:21 编辑
这个问题其实以前解决过,但由于硬盘故障而将方法遗失,故再向诸位大侠请教。
普通情况下在存档和读档处显示的是角色行走图。用什么方法可以将行走图换成特定文件夹中的头像?只记得是在Window_SaveFile中的52行改,忘的是具体方法
我用了下面的脚本,一并附上
#在覆盖存档的时候弹出对话框提示
class Scene_Save < Scene_File
# -----------------------------
def initialize
super("储存到哪一个进度")
@confirm_window = Window_Base.new(120, 188, 400, 64)
@confirm_window.contents = Bitmap.new(368, 32)
string = "要覆盖先前的进度吗?"
@confirm_window.contents.font.name = "楷体_GB2312"
@confirm_window.contents.font.size = 24
@confirm_window.contents.draw_text(4, 0, 368, 32, string)
@yes_no_window = Window_Command.new(100, ["覆盖", "取消"])
@confirm_window.visible = false
@confirm_window.z = 1500
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@yes_no_window.x = 270
@yes_no_window.y = 252
@yes_no_window.z = 1500
@mode = 0
end
# -----------------------------
def on_decision(filename)
if FileTest.exist?(filename)
@confirm_window.visible = true
@yes_no_window.visible = true
@yes_no_window.active = true
@mode = 1
else
$game_system.se_play($data_system.save_se)
file = File.open(filename, "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
end
# -----------------------------
def update
if @mode == 0
super
else
@help_window.update
@yes_no_window.update
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if @yes_no_window.index == 0
@yes_no_window.visible = false
@yes_no_window.active = false
@confirm_window.visible = false
filename = make_filename(@file_index)
$game_system.se_play($data_system.save_se)
file = File.open(filename, "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
else
$scene = Scene_Menu.new(4)
end
else
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@mode = 0
end
end
if Input.trigger?(Input::B)
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@mode = 0
return
end
end
end
# -----------------------------
def on_cancel
$game_system.se_play($data_system.cancel_se)
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
# -----------------------------
def write_save_data(file)
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
$game_system.save_count += 1
$game_system.magic_number = $data_system.magic_number
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end
class Scene_File
alias carol3_main main
def main
carol3_main
if self.is_a?(Scene_Save)
@confirm_window.dispose
@yes_no_window.dispose
end
end
end
复制代码
作者:
忧雪の伤
时间:
2011-2-12 15:25
本帖最后由 忧雪の伤 于 2011-2-12 15:51 编辑
行走图换成特定文件夹中的头像
创建base的一个新类来描绘头像。
def xxxxx
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
@xxx = Sprite.new
@xxx.bitmap = Bitmap.new("位置" + actor.name)
end
end
复制代码
作者:
步兵中尉
时间:
2011-2-12 16:01
问题是你的这个东西放什么地方?
作者:
忧雪の伤
时间:
2011-2-12 16:05
步兵中尉 发表于 2011-2-12 16:01
问题是你的这个东西放什么地方?
龙骑士徒有虚名……
window_base第一个END下面。
作者:
步兵中尉
时间:
2011-2-12 21:53
按你的做法又牵扯到了我其它的地方。
后来记起了一种简单的制作法,不需要改动base,只直接改动Window_SaveFile就能实现
# 描绘角色
for i in
[email protected]
bitmap=RPG::Cache.battler(@characters[i][0], @characters[i][1])
zoom_x = 80 / bitmap.width
zoom_y = 80 / bitmap.height
src_rect = Rect.new(0, 0, 85, 85) #——可自己调整大小
x = 300 - @characters.size * 40 + i * 82 - bitmap.width / 2 + 11
self.contents.blt(x, -3, bitmap, src_rect)
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1