Project1
标题: 新手想请教如何更改立绘和物品栏的排版和图片 [打印本页]
作者: wangxiaojiav6 时间: 2016-10-24 18:12
标题: 新手想请教如何更改立绘和物品栏的排版和图片 本帖最后由 wangxiaojiav6 于 2016-10-25 11:37 编辑
新手刚入坑,研究了两天va,但脚本一直不是很明白……(代码苦手……)
想做出立绘在对话框前面的效果,找到了一个可以实现的脚本,但是出现了字体离立绘太远的问题……大概离了8个字左右的距离。立绘图片是贴边剪裁的,想到是不是脚本中字体位置设置的问题但不知道哪里才是修改的代码……
还有想将默认的物品栏的排版和图片换成自己的素材……这几天找了不少一直没找到,求大神们指教QWQ…………谢谢
下面是找的脚本
#encoding:utf-8
#==============================================================================
# ■ 半身像对话框 by LBQ
#------------------------------------------------------------------------------
# 一个简单的半身像对话框罢了= =
#------------------------------------------------------------------------------
# ■ 用法一览
# 1:如何将半身像应用到游戏中?
# ——如果想要把一个脸图替换成半身像,则需要找到这个脸图的编号,比如说拉尔
# 夫,就是Actor1的编号0,之后去在Graphics/Busts这个文件夹里面拷贝一个
# 叫做Actor1_0的图像,这个图像会被当做半身像替换原有图像。
#==============================================================================
# 2013.8.25 => 修复存档不能Bug (感谢小刀
#==============================================================================
$imported ||= {}
$imported[:LBQ_Bust]=true
module LBQ
module Bust
FOLDER="Busts"
SUB1=[/【/, "\\{\\c[6]-- "]
SUB2=[/】/, " --\\c[0]\\}"]
TEXT_FOR_NEXT="[next]"
TEXT_FOR_END ="[end]"
INDENT=255 #半身像的缩进
end
end
module Cache
def self.busts(filename)
load_bitmap("Graphics/#{LBQ::Bust::FOLDER}/", filename)
end
end
class Sprite_Bust < Sprite_Base
attr_accessor :bust_graphics
attr_accessor :status
def initialize(vp=nil)
super(vp)
@bust_graphics=nil
@status=:nothing
end
def slide_in
@status=:sliding_in
end
def slide_out
@status=:sliding_out
if $game_temp.do_not_slide_out
@status=:slided_out
set_pos
end
end
def set_pos(slide_in=true)
self.x=0 - self.bitmap.width
self.y=Graphics.height-self.bitmap.height
self.x=0 unless slide_in
end
def set_graphics(bust_graphics)
self.bitmap=Cache.busts(bust_graphics)
end
def update
super
case @status
when :nothing
# Do Nothing
when :sliding_in
#Slide In
self.x+=12
if self.x>=0
self.x=0
@status=:slided_in
end
when :sliding_out
self.x-=12
if self.x<= -self.bitmap.width
self.x= -self.bitmap.width
@status=:slided_out
end
#Slide Out
when :slided_in
#Slided in
when :slided_out
#Sliede out
end
end
end
class Game_Temp
attr_accessor :bust_name
attr_accessor :bust
attr_accessor :have_bust
attr_accessor :do_not_slide_out
alias lbq_bust_shot_game_message_init initialize
def initialize
lbq_bust_shot_game_message_init
@bust_name=""
@bust=nil
@have_bust=false
@do_not_slide_out=false
end
end
class Game_Message
#--------------------------------------------------------------------------
# ● 添加内容
#--------------------------------------------------------------------------
def add(text)
new_text=text.gsub(LBQ::Bust::SUB1[0],LBQ::Bust::SUB1[1])
new_text2=new_text.gsub(LBQ::Bust::SUB2[0],LBQ::Bust::SUB2[1])
if new_text2.include? LBQ::Bust::TEXT_FOR_NEXT
new_text2.delete!(LBQ::Bust::TEXT_FOR_NEXT)
$game_temp.do_not_slide_out=true
end
if new_text2.include? LBQ::Bust::TEXT_FOR_END
new_text2.delete!(LBQ::Bust::TEXT_FOR_END)
$game_temp.do_not_slide_out=false
end
@texts.push(new_text2)
end
end
class Game_Interpreter
alias lbq_bust_shot_command_101 command_101
#--------------------------------------------------------------------------
# ● 显示文字
#--------------------------------------------------------------------------
def command_101
$game_temp.bust=nil
unless @params[0].empty?
if File.exist?("Graphics/#{LBQ::Bust::FOLDER}/#{@params[0]}_#{@params[1]}.png")
$game_temp.have_bust=true
else
$game_temp.have_bust=false
$game_temp.bust_name=""
end
end
unless @params[3] == 2
$game_temp.have_bust=false
end
if $game_temp.have_bust
$game_temp.bust_name="#{@params[0]}_#{@params[1]}"
$game_temp.bust=nil
$game_temp.bust=Sprite_Bust.new
$game_temp.bust.set_graphics($game_temp.bust_name)
$game_temp.bust.z=888
unless $game_temp.do_not_slide_out
$game_temp.bust.set_pos
$game_temp.bust.slide_in
else
$game_temp.bust.set_pos(false)
$game_temp.bust.slide_in
end
end
lbq_bust_shot_command_101
if $game_temp.have_bust
$game_temp.bust.slide_out
Fiber.yield until $game_temp.bust.status==:slided_out
end
$game_temp.have_bust=false
$game_temp.bust_name=""
end
alias lbq_bust_int_update update
def update
lbq_bust_int_update
$game_temp.bust.update unless $game_temp.bust.nil?
end
end
class Window_Message
#--------------------------------------------------------------------------
# ● 获取换行位置
#--------------------------------------------------------------------------
def new_line_x
# 如果有头像
unless $game_message.face_name.empty?
value=112
value=LBQ::Bust::INDENT unless $game_temp.bust_name.empty?
# 木有
else
value=0
end
return value
end
end
#~ class Window_Message
#--------------------------------------------------------------------------
# ● 翻页处理
#--------------------------------------------------------------------------
#~ def new_page(text, pos)
#~ contents.clear
#~ draw_face($game_message.face_name, $game_message.face_index, 0, 0) if $game_temp.bust_name.empty?
#~ reset_font_settings
#~ pos[:x] = new_line_x
#~ pos[:y] = 0
#~ pos[:new_x] = new_line_x
#~ pos[:height] = calc_line_height(text)
#~ clear_flags
#~ end
#~ end
只看得懂z控制文字在最远,以便在最上面显示……在哪里修改xy就不太明白了……在不显示立绘的情况下,怎么让文字的位置回复到最左边呢?求教QAQ,谢谢
物品栏是想做出这种感觉的,不太懂怎么修改……
作者: RaidenInfinity 时间: 2016-10-25 12:06
你的第一个问题的解决方法主要是在这一段
class Window_Message
#--------------------------------------------------------------------------
# ● 获取换行位置
#--------------------------------------------------------------------------
def new_line_x
# 如果有头像
unless $game_message .face_name .empty ?
value=112
value=LBQ::Bust::INDENT unless $game_temp .bust_name .empty ?
# 木有
else
value=0
end
return value
end
end
class Window_Message
#--------------------------------------------------------------------------
# ● 获取换行位置
#--------------------------------------------------------------------------
def new_line_x
# 如果有头像
unless $game_message .face_name .empty ?
value=112
value=LBQ::Bust::INDENT unless $game_temp .bust_name .empty ?
# 木有
else
value=0
end
return value
end
end
因为并未提供工程,所以我只能凭着脚本作猜测。new_line_x这个方法,决定文字显示的X值。如果在事件指令中没有指定脸图,那么X值会是0。“在不显示立绘的情况下,怎么让文字的位置回复到最左边” 的这个问题,我不觉得有问题,这个得实际看到工程测试了才能理解。那么下列的这两行:
value=112
value=LBQ::Bust::INDENT unless $game_temp .bust_name .empty ?
value=112
value=LBQ::Bust::INDENT unless $game_temp .bust_name .empty ?
这个脚本呢,如果有提供立绘,那就使用 LBQ::Bust::INDENT 这个常量来决定X值,否则使用112(普通脸图)。
“字体离立绘太远”的这个问题,解决的方法有两种,一是更改常量:
$imported ||= { }
$imported [ :LBQ_Bust ] =true
module LBQ
module Bust
FOLDER="Busts"
SUB1=[ /【/, "\\ {\\ c[6]-- " ]
SUB2=[ /】/, " --\\ c[0]\\ }" ]
TEXT_FOR_NEXT="[next]"
TEXT_FOR_END ="[end]"
INDENT=255 #半身像的缩进 <----把255改成你觉得合适的X值 … 然后我要吐槽下LBQ大佬啊你为啥等号前后不加空格
end
end
$imported ||= { }
$imported [ :LBQ_Bust ] =true
module LBQ
module Bust
FOLDER="Busts"
SUB1=[ /【/, "\\ {\\ c[6]-- " ]
SUB2=[ /】/, " --\\ c[0]\\ }" ]
TEXT_FOR_NEXT="[next]"
TEXT_FOR_END ="[end]"
INDENT=255 #半身像的缩进 <----把255改成你觉得合适的X值 … 然后我要吐槽下LBQ大佬啊你为啥等号前后不加空格
end
end
二就是舍弃常量,直接定义数值:
value = 200 unless $game_temp .bust_name .empty ? #把200改成你觉得合适的X值
value = 200 unless $game_temp .bust_name .empty ? #把200改成你觉得合适的X值
至于第二个问题,“将默认的物品栏的排版和图片换成自己的素材”,没有详细的资讯(排版成怎么样?什么素材?之类的)大概是帮不了。
不过如果需要的话,可以使用论坛的私信功能联系我,可能可以帮上忙,定制所需的脚本。
作者: wangxiaojiav6 时间: 2016-10-25 13:09
非常感谢这么细致的回复,按照你的方法已经解决了。QWQ,谢谢你。
排版的话是希望能做出上面那个图的感觉,还在看论坛的教程,想看看能不能根据更改背景图片和窗口位置实现。(很喜欢深海囚人的菜单栏……)
再次感谢你的帮助QWQ,谢谢大神~~
作者: 魔法丶小肉包 时间: 2016-10-25 23:30
根据楼主给出的菜单要求↓
效果图:
脚本↓
module MFXRB
ITEM = "ITEM"
SKILL= "MAGIC"
EQUIP= "EQI"
SAVE = "SAVE"
GEND = "SHUT DOWN"
SAVETEXT="CONTINUE"
FILE = "DATA"
FH = "☆"
FHF = "△"
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 ] = $game_map .display_name
header[ :lv ] = $game_party .leader .level
header[ :hp ] = $game_party .leader .hp
header[ :face ] = $game_party .face_for_savefile
header
end
end
class Game_Party < Game_Unit
def face_for_savefile
battle_members.collect do |actor|
[ actor.face_name , actor.face_index ]
end
end
end
class Scene_Menu < Scene_MenuBase
def create_command_window
@command_window = Window_MenuCommand.new
@command_window .set_handler ( :item , method( :command_item ) )
@command_window .set_handler ( :skill , method( :command_personal ) )
@command_window .set_handler ( :equip , method( :command_personal ) )
@command_window .set_handler ( :save , method( :command_save ) )
@command_window .set_handler ( :game_end , method( :command_game_end ) )
@command_window .set_handler ( :cancel , method( :return_scene ) )
end
end
class Window_MenuCommand < Window_Command
def make_command_list
add_main_commands
add_original_commands
add_save_command
add_game_end_command
end
def add_main_commands
add_command( MFXRB::FH +MFXRB::ITEM , :item , main_commands_enabled)
add_command( MFXRB::FH +MFXRB::SKILL , :skill , main_commands_enabled)
add_command( MFXRB::FH +MFXRB::EQUIP , :equip , main_commands_enabled)
end
def add_save_command
add_command( MFXRB::FH +MFXRB::SAVE , :save , save_enabled)
end
def add_game_end_command
add_command( MFXRB::FH +MFXRB::GEND , :game_end )
end
end
class Window_MenuStatus < Window_Selectable
def draw_item( index)
actor = $game_party .members [ index]
enabled = $game_party .battle_members .include ?( actor)
rect = item_rect( index)
draw_item_background( index)
draw_actor_face( actor, rect.x + 1 , rect.y + 1 , enabled)
draw_actor_name( actor, rect.x + 100 , rect.y + 1 )
draw_actor_class( actor, rect.x + 250 , rect.y + 1 )
draw_actor_level( actor, rect.x + 100 , rect.y + line_height)
d_a_zt( actor,rect.x + 180 , rect.y + line_height)
d_ah( actor, rect.x + 240 , rect.y + line_height)
d_aexp( actor, rect.x + 100 , rect.y + line_height*2 )
d_am( actor, rect.x + 240 , rect.y + line_height*2 )
end
end
class Window_Base < Window
def d_a_zt( actor,x,y,width=100 )
draw_text_ex( x,y,if actor.dead ?;"死亡" ;else "正常" ;end)
end
def d_ah( actor, x, y)
draw_text( x, y, 30 , line_height, Vocab::hp_a)
draw_text( x + 35 , y, 100 , line_height, actor.hp .to_s +"/" +actor.mhp .to_s )
end
def d_am( actor, x, y, width = 124 )
draw_text( x, y, 30 , line_height, Vocab::mp_a)
draw_text( x + 35 , y, 100 , line_height, actor.mp .to_s +"/" +actor.mmp .to_s )
end
def d_aexp( actor, x, y, width = 124 )
s1 = actor.max_level ? ? "-------" : actor.exp
s2 = actor.max_level ? ? "-------" : actor.next_level_exp - actor.exp
draw_text( x, y, 30 , line_height, "E" )
draw_text( x + 35 , y, 100 , line_height, s1.to_s +"/" +s2.to_s )
end
end
class Scene_File < Scene_MenuBase
def visible_max
return 3
end
end
class Scene_Save < Scene_File
def help_window_text
MFXRB::FH +MFXRB::SAVETEXT +MFXRB::FH
end
end
class Window_SaveFile < Window_Base
def refresh
contents.clear
change_color( normal_color)
name = MFXRB::FHF +MFXRB::FILE + " #{@file_index + 1}"
draw_text( 4 , 0 , 200 , line_height, name)
@name_width = text_size( name) .width
draw_party_face( 140 , y)
draw_map( -490 , y + line_height)
draw_lv( -490 , y + line_height*2 )
draw_shp( -400 , y + line_height*2 )
end
def draw_map( x, y)
header = DataManager.load_header ( @file_index)
return unless header
draw_text( x, y, width, line_height, header[ :map ] , 2 )
end
def draw_lv( x, y)
header = DataManager.load_header ( @file_index)
return unless header
draw_text( x, y, width, line_height, "LV " +header[ :lv ] .to_s , 2 )
end
def draw_shp( x, y)
header = DataManager.load_header ( @file_index)
return unless header
draw_text( x, y, width, line_height, "HP " +header[ :hp ] .to_s , 2 )
end
def draw_party_face( x, y)
header = DataManager.load_header ( @file_index)
return unless header && header[ :face ]
header[ :face ] .each_with_index do |data, i|
draw_face( data[ 0 ] , data[ 1 ] , x + i * 96 , y)
end
end
end
module MFXRB
ITEM = "ITEM"
SKILL= "MAGIC"
EQUIP= "EQI"
SAVE = "SAVE"
GEND = "SHUT DOWN"
SAVETEXT="CONTINUE"
FILE = "DATA"
FH = "☆"
FHF = "△"
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 ] = $game_map .display_name
header[ :lv ] = $game_party .leader .level
header[ :hp ] = $game_party .leader .hp
header[ :face ] = $game_party .face_for_savefile
header
end
end
class Game_Party < Game_Unit
def face_for_savefile
battle_members.collect do |actor|
[ actor.face_name , actor.face_index ]
end
end
end
class Scene_Menu < Scene_MenuBase
def create_command_window
@command_window = Window_MenuCommand.new
@command_window .set_handler ( :item , method( :command_item ) )
@command_window .set_handler ( :skill , method( :command_personal ) )
@command_window .set_handler ( :equip , method( :command_personal ) )
@command_window .set_handler ( :save , method( :command_save ) )
@command_window .set_handler ( :game_end , method( :command_game_end ) )
@command_window .set_handler ( :cancel , method( :return_scene ) )
end
end
class Window_MenuCommand < Window_Command
def make_command_list
add_main_commands
add_original_commands
add_save_command
add_game_end_command
end
def add_main_commands
add_command( MFXRB::FH +MFXRB::ITEM , :item , main_commands_enabled)
add_command( MFXRB::FH +MFXRB::SKILL , :skill , main_commands_enabled)
add_command( MFXRB::FH +MFXRB::EQUIP , :equip , main_commands_enabled)
end
def add_save_command
add_command( MFXRB::FH +MFXRB::SAVE , :save , save_enabled)
end
def add_game_end_command
add_command( MFXRB::FH +MFXRB::GEND , :game_end )
end
end
class Window_MenuStatus < Window_Selectable
def draw_item( index)
actor = $game_party .members [ index]
enabled = $game_party .battle_members .include ?( actor)
rect = item_rect( index)
draw_item_background( index)
draw_actor_face( actor, rect.x + 1 , rect.y + 1 , enabled)
draw_actor_name( actor, rect.x + 100 , rect.y + 1 )
draw_actor_class( actor, rect.x + 250 , rect.y + 1 )
draw_actor_level( actor, rect.x + 100 , rect.y + line_height)
d_a_zt( actor,rect.x + 180 , rect.y + line_height)
d_ah( actor, rect.x + 240 , rect.y + line_height)
d_aexp( actor, rect.x + 100 , rect.y + line_height*2 )
d_am( actor, rect.x + 240 , rect.y + line_height*2 )
end
end
class Window_Base < Window
def d_a_zt( actor,x,y,width=100 )
draw_text_ex( x,y,if actor.dead ?;"死亡" ;else "正常" ;end)
end
def d_ah( actor, x, y)
draw_text( x, y, 30 , line_height, Vocab::hp_a)
draw_text( x + 35 , y, 100 , line_height, actor.hp .to_s +"/" +actor.mhp .to_s )
end
def d_am( actor, x, y, width = 124 )
draw_text( x, y, 30 , line_height, Vocab::mp_a)
draw_text( x + 35 , y, 100 , line_height, actor.mp .to_s +"/" +actor.mmp .to_s )
end
def d_aexp( actor, x, y, width = 124 )
s1 = actor.max_level ? ? "-------" : actor.exp
s2 = actor.max_level ? ? "-------" : actor.next_level_exp - actor.exp
draw_text( x, y, 30 , line_height, "E" )
draw_text( x + 35 , y, 100 , line_height, s1.to_s +"/" +s2.to_s )
end
end
class Scene_File < Scene_MenuBase
def visible_max
return 3
end
end
class Scene_Save < Scene_File
def help_window_text
MFXRB::FH +MFXRB::SAVETEXT +MFXRB::FH
end
end
class Window_SaveFile < Window_Base
def refresh
contents.clear
change_color( normal_color)
name = MFXRB::FHF +MFXRB::FILE + " #{@file_index + 1}"
draw_text( 4 , 0 , 200 , line_height, name)
@name_width = text_size( name) .width
draw_party_face( 140 , y)
draw_map( -490 , y + line_height)
draw_lv( -490 , y + line_height*2 )
draw_shp( -400 , y + line_height*2 )
end
def draw_map( x, y)
header = DataManager.load_header ( @file_index)
return unless header
draw_text( x, y, width, line_height, header[ :map ] , 2 )
end
def draw_lv( x, y)
header = DataManager.load_header ( @file_index)
return unless header
draw_text( x, y, width, line_height, "LV " +header[ :lv ] .to_s , 2 )
end
def draw_shp( x, y)
header = DataManager.load_header ( @file_index)
return unless header
draw_text( x, y, width, line_height, "HP " +header[ :hp ] .to_s , 2 )
end
def draw_party_face( x, y)
header = DataManager.load_header ( @file_index)
return unless header && header[ :face ]
header[ :face ] .each_with_index do |data, i|
draw_face( data[ 0 ] , data[ 1 ] , x + i * 96 , y)
end
end
end
作者: wangxiaojiav6 时间: 2016-10-26 16:42
太感谢了!!!{:2_249:}好棒啊!!!QWQ,多谢大神拯救代码手残…………
作者: 魔法丶小肉包 时间: 2016-10-26 17:16
不好意思,刚刚发现原来存档界面的是领队角色名而不是地图名,请把下面的脚本放在楼上脚本的下面
module DataManager
def self .make_save_header
header = { }
header[ :characters ] = $game_party .characters_for_savefile
header[ :playtime_s ] = $game_system .playtime_s
header[ :name ] = $game_party .leader .name
header[ :lv ] = $game_party .leader .level
header[ :hp ] = $game_party .leader .hp
header[ :face ] = $game_party .face_for_savefile
header
end
end
class Window_SaveFile < Window_Base
def refresh
contents.clear
change_color( normal_color)
name = MFXRB::FHF +MFXRB::FILE + " #{@file_index + 1}"
draw_text( 4 , 0 , 200 , line_height, name)
@name_width = text_size( name) .width
draw_party_face( 140 , y)
draw_an( -470 , y + line_height)
draw_lv( -490 , y + line_height*2 )
draw_shp( -400 , y + line_height*2 )
end
def draw_an( x, y)
header = DataManager.load_header ( @file_index)
return unless header
draw_text( x, y, width, line_height, header[ :name ] , 2 )
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[ :name ] = $game_party .leader .name
header[ :lv ] = $game_party .leader .level
header[ :hp ] = $game_party .leader .hp
header[ :face ] = $game_party .face_for_savefile
header
end
end
class Window_SaveFile < Window_Base
def refresh
contents.clear
change_color( normal_color)
name = MFXRB::FHF +MFXRB::FILE + " #{@file_index + 1}"
draw_text( 4 , 0 , 200 , line_height, name)
@name_width = text_size( name) .width
draw_party_face( 140 , y)
draw_an( -470 , y + line_height)
draw_lv( -490 , y + line_height*2 )
draw_shp( -400 , y + line_height*2 )
end
def draw_an( x, y)
header = DataManager.load_header ( @file_index)
return unless header
draw_text( x, y, width, line_height, header[ :name ] , 2 )
end
end
作者: wangxiaojiav6 时间: 2016-10-26 17:47
QWQ谢谢!!太感谢你了,已经放进去运行成功了~~大神受我一拜qwq
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1