Project1
标题: 请问如何使存档显示角色图像和地图名 [打印本页]
作者: asdwds 时间: 2013-6-23 16:08
标题: 请问如何使存档显示角色图像和地图名 请问如何使用 header[: ] 这般的代码,我想要让存档显示角色图像和地图名
我在DataManager--header[:map_name] = $game_map.display_name
Window_SaveFile运用时,header[:map_name]告诉我[]错误。
我还写了header[:faces]用来存actor.face_name和index
header[:faces].each_with_index do |data, i|动作,each_with_index报错
想问下如何才能使存档显示角色图像和地图名
作者: Sion 时间: 2013-6-23 16:16
存地图名header[:map_name] = $game_map.name_display # 地图名 复制代码 读取的时候展开map_name = DataManager.load_header(存档索引)[:map_name] 复制代码 保存跟绘制脸图就修改下面的两个方法吧:def characters_for_savefile 复制代码 def draw_party_characters(x, y) 复制代码
作者: asdwds 时间: 2013-6-23 17:58
Sion 发表于 2013-6-23 16:16
存地图名读取的时候展开保存跟绘制脸图就修改下面的两个方法吧:
我新写了 [:faces] = battle_members.collect do |actor|
[actor.face_name, actor.face_index]
end
然后使用到def draw_faces(x, y)中,header[:face].each_with_index do |data, i| 的.each_with_index报错
请问是为什么?
作者: asdwds 时间: 2013-6-23 19:00
本帖最后由 asdwds 于 2013-6-23 19:08 编辑
Sion 发表于 2013-6-23 16:16
存地图名读取的时候展开保存跟绘制脸图就修改下面的两个方法吧:
each_with_index 和 [:map_name]的[]未定义报错,请问是为什么?
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# 管理队伍的类。保存有金钱及物品的信息。本类的实例请参考 $game_party 。
#==============================================================================
#--------------------------------------------------------------------------
# ● 存档文件显示用的角色图
#--------------------------------------------------------------------------
def faces_for_savefile
battle_members.collect do |actor|
[actor.face_name, actor.face_index]
end
end
#==============================================================================
# ■ Window_SaveFile
#==============================================================================
class Window_SaveFile < Window_Base
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
change_color(normal_color)
name = Vocab::File + " #{@file_index + 1}"
draw_text(4, 0, 200, line_height, name)
@name_width = text_size(name).width
draw_playtime(0, 34, contents.width - 4, 2)
draw_party_faces(100, -10)
map_name = DataManager.load_header(@file_index)[:map_name] #说[]错误
draw_text(320-16, 0, 200, 32, map_name, 2)
end
#--------------------------------------------------------------------------
# ● 画角色图
#--------------------------------------------------------------------------
def draw_party_faces(x, y)
header = DataManager.load_header(@file_index)
return unless header
header[:faces].each_with_index do |data, i| #each_with_index 报错
draw_character(data[0], data[1], x + i * 48, y)
end
end
end
#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
# 数据库和游戏实例的管理器。所有在游戏中使用的全局变量都在这里初始化。
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# ● 生成存档的头数据
#--------------------------------------------------------------------------
def self.make_save_header
header = {}
header[:characters] = $game_party.characters_for_savefile
header[:playtime_s] = $game_system.playtime_s
header[:faces] = $game_party.faces_for_savefile
header[:map_name] = $game_map.display_name
header
end
end
作者: asdwds 时间: 2013-6-23 19:51
asdwds 发表于 2013-6-23 17:58
我新写了 [:faces] = battle_members.collect do |actor|
[actor.face_nam ...
如何判断是否有存档存在?
def checkheader
@header = DataManager.load_header(@file_index)
return true if @header
end
我用这个判断了,然后现在不能保存了
作者: Sion 时间: 2013-6-23 20:20
asdwds 发表于 2013-6-23 19:51
如何判断是否有存档存在?
def checkheader
@header = DataManager.load_header(@file_index)class Game_Party
def characters_for_savefile
battle_members.collect do |actor|
[actor.character_name, actor.character_index,
actor.face_name, actor.face_index]
end
end
end
class Window_SaveFile
def draw_party_characters(x, y)
header = DataManager.load_header(@file_index)
return unless header
header[:characters].each_with_index do |data, i|
draw_character(data[0], data[1], x + i * 48, y)
draw_character_face(data[2], data[3], x, y)
end
draw_saved_map_name(header[:map_name], x, y)
end
def draw_character_face(face_name, face_index, x, y)
end
def draw_saved_map_name(name, x, y)
end
end
module DataManager
def self.make_save_header
header = {}
header[:characters] = $game_party.characters_for_savefile
header[:playtime_s] = $game_system.playtime_s
header[:map_name] = $game_map.display_name
header
end
end 复制代码
作者: asdwds 时间: 2013-6-23 20:31
Sion 发表于 2013-6-23 20:20
依旧不能存档,打开存档界面,按存档后会发出存档不能的声音
作者: bobcaocheng 时间: 2013-6-23 20:38
感觉不是简单的事情啊……我试了一下,写出数据有难度啊。
作者: asdwds 时间: 2013-6-24 17:05
Sion 发表于 2013-6-23 20:20
header是不是有容量限制?为什么一定要是characters和characters_for_savefile
只要不是这个的,都会存档不成功
作者: asdwds 时间: 2013-6-24 19:29
Sion 发表于 2013-6-23 20:20
现在我已经没有太大的问题了,header好像是有容量限制
角色的图像如果不是在一张png里面的话,就只会出现角色1的图像,如果以角色2保存的话,就是黑的(没图片)
作者: j433463 时间: 2013-6-25 07:53
容量限制?没有吧,我都能正常做到显示角色图像和地图名:
这是我尝试仿轩辕剑存档格式画面的截图,我有成功了喔!
作者: j433463 时间: 2013-6-25 08:35
1. 在 DataManager 的 def self.make_save_header 是这样的:
def self .make_save_header
header = { }
header[ :characters ] = $game_party .characters_for_savefile
header[ :playtime_s ] = $game_system .playtime_s
header[ :mapname ] = ( $game_map.display_name .size > 0 ? $game_map .display_name : '未命名' )
header[ :faces ] = $game_party .faces_for_savefile
header
end
def self .make_save_header
header = { }
header[ :characters ] = $game_party .characters_for_savefile
header[ :playtime_s ] = $game_system .playtime_s
header[ :mapname ] = ( $game_map.display_name .size > 0 ? $game_map .display_name : '未命名' )
header[ :faces ] = $game_party .faces_for_savefile
header
end
2. 在 Game_Party 的 def characters_for_savefile 下方,加这么一行:
#--------------------------------------------------------------------------
# ● 存档档案显示用的角色脸图讯息
#--------------------------------------------------------------------------
def faces_for_savefile
battle_members.collect do |actor|
[ actor.face_name , actor.face_index ]
end
end
#--------------------------------------------------------------------------
# ● 存档档案显示用的角色脸图讯息
#--------------------------------------------------------------------------
def faces_for_savefile
battle_members.collect do |actor|
[ actor.face_name , actor.face_index ]
end
end
3. 在 Window_SaveFile 的 def refresh 要这样改:
def refresh
contents.clear
change_color( normal_color)
name = Vocab::File + " #{@file_index + 1}"
draw_text( 4 , 0 , 200 , line_height, name)
@name_width = text_size( name) .width
#draw_party_characters(152, 58)
draw_party_faces( 80 , 58 ) #<--- 描绘脸图
draw_playtime( 0 , contents.height - line_height, contents.width - 4 , 2 )
header = DataManager.load_header ( @file_index)
return unless header
draw_text( 620 , 0 , 200 , line_height, header[ :mapname ] ) #<--- 描绘地图名
end
def refresh
contents.clear
change_color( normal_color)
name = Vocab::File + " #{@file_index + 1}"
draw_text( 4 , 0 , 200 , line_height, name)
@name_width = text_size( name) .width
#draw_party_characters(152, 58)
draw_party_faces( 80 , 58 ) #<--- 描绘脸图
draw_playtime( 0 , contents.height - line_height, contents.width - 4 , 2 )
header = DataManager.load_header ( @file_index)
return unless header
draw_text( 620 , 0 , 200 , line_height, header[ :mapname ] ) #<--- 描绘地图名
end
然后,在 def draw_party_characters(x, y) 的下方,加这么一段:
def draw_party_characters( x, y)
header = DataManager.load_header ( @file_index)
return unless header
header[ :faces ] .each_with_index do |data, i|
draw_face( data[ 0 ] , data[ 1 ] , x + i * 96 , 10 )
end
end
def draw_party_characters( x, y)
header = DataManager.load_header ( @file_index)
return unless header
header[ :faces ] .each_with_index do |data, i|
draw_face( data[ 0 ] , data[ 1 ] , x + i * 96 , 10 )
end
end
就这样而已,没有那么复杂...
作者: scottyfan 时间: 2013-6-26 18:56
实际上LZ还不如用图书馆里那个截图存档,然后在那个脚本里改一改。
作者: asdwds 时间: 2013-6-26 21:41
j433463 发表于 2013-6-25 08:35
1. 在 DataManager 的 def self.make_save_header 是这样的:
def self.make_save_header
以下使用后,会触发on_savefile_ok的else条件
#==============================================================================
# ■ Game_Party
#==============================================================================
def faces_for_savefile
battle_members.collect do |actor|
[actor.face_name, actor.face_index]
end
end
#==============================================================================
# ■ Window_SaveFile
#==============================================================================
class Window_SaveFile < Window_Base
def refresh
contents.clear
change_color(normal_color)
name = Vocab::File + " #{@file_index + 1}"
draw_text(4, 0, 200, line_height, name)
@name_width = text_size(name).width
draw_party_faces(80, 58) #<--- 描绘脸图
draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
header = DataManager.load_header(@file_index)
return unless header
draw_text(620, 0, 200, line_height, header[:mapname]) #<--- 描绘地图名
end
def draw_party_faces(x, y)
header = DataManager.load_header(@file_index)
return unless header
header[:faces].each_with_index do |data, i|
draw_face(data[0], data[1], x + i * 96, 10)
end
end
end
#==============================================================================
# ■ DataManager
#==============================================================================
module DataManager
def self.make_save_header
header = {}
header[:characters] = $game_party.characters_for_savefile
header[:playtime_s] = $game_system.playtime_s
header[:mapname] = $game_map.display_name
header[:faces] = $game_party.faces_for_savefile
header
end
end
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1