Project1
标题:
怎么在对话时加图片啊
[打印本页]
作者:
心倾河中
时间:
2012-8-1 13:33
标题:
怎么在对话时加图片啊
本帖最后由 心倾河中 于 2012-8-1 13:34 编辑
我想在对话时加人物图片,可弄不明白。谁能教教我吗? dsu_plus_rewardpost_czw
作者:
woyaozhuce
时间:
2012-8-1 14:29
本帖最后由 hcm 于 2012-8-11 13:35 编辑
问题不明确哟。
你是想在对话框里的左边加入角色图片是么?
你的对话框脚本是默认还是别的呢。
默认的话是不能加入图片的哟,除非你用的是vx或者va
我给你一个对话框脚本
# 1. 此脚本主要是解决了在1.03版XP上的方块问题,以及增加了一些功能
#
# 2. 人名美化使用方法与以前一样
#
# 3. 默认人物头像在左边显示
# 如果需要右边显示,在输入的名称之后加"@r"即可
# 例: "阿尔西斯@r:"(注意必须小写)
#
# 4. 在对话中更改字体的方法:
# \f[X]:更改字号为X
#
# 5. 在对话中显示(技能 物品 武器 防具 人物)图标和名称的方法:
# \s[X]: 显示第X号技能图标和名称
# \i[X]: 显示第X号物品图标和名称
# \w[X]: 显示第X号武器图标和名称
# \a[X]: 显示第X号防具图标和名称
# \r[X]: 显示第X号人物图标和名称
#
# 6. 在对话中更改文字不透明度的方法:
# \o[X]: 把文字不透明度更改为X (取值范围为0~255)
#
# 7. 在对话中关闭或开启拟声音效的方法:
# \q:默认开启时,执行一次关闭,再执行一次则开启
#
# 8. 如果需要自定义字体颜色,
# 可以打开"Graphics/Windowskins"目录下的"Window.png"文件查看
# 使用方法与VX类似
#
# 素材要求:
# 1. 要求所有半身像朝向一致(默认是正面偏右)
#
#--------------------------------------------------------------------------
# ● 参数设置
#--------------------------------------------------------------------------
# 预设字体组
FONT_ARRAY = ["黑体", "宋体", "仿宋_GB2312"]
# 控制显示尾部图标的开关号
TAIL_SHOW = true
# 头像图片保存目录的设定
FACE_PIC_DIR = "Graphics/Faces/"
# 呼出对话框用Skin设定
FUKI_SKIN_NAME = "Window"
# 字体大小
MES_FONT_SIZE = 20
# 字体颜色
FUKI_COLOR = Color.new(100, 100, 0, 255)
# 窗口透明度
FUKI_OPACITY = 200 # 呼出对话框
MES_OPACITY = 160 # 默认信息窗口
# 窗口表示时是否根据画面大小自动检查窗口出现的位置,
# 自动改变位置( true / false )
POS_FIX = true
# 角色高度尺寸
CHARACTOR_HEIGHT = 50
# 呼出对话框的相对位置(纵坐标)
POP_SHIFT_TOP = 0 # 表示位置为上的时候
POP_SHIFT_UNDER = -4 # 表示位置为下的时候
# 信息的表示速度(数字越小速度越快,0为瞬间表示)
# 游戏中 可随时用数字代入 $mes_speed 来改变消息表示速度。
MES_SPEED = 1
$play_voice = true
$mes_name = ""
$mes_id = nil
#==============================================================================
#==============================================================================
# 方便用户同时设置2个常用参数而使用的函数
#==============================================================================
def chat(id = nil,name = "")
$mes_id = id
$mes_name = name
end
#==============================================================================
# □ Game_Temp
#==============================================================================
class Game_Temp
attr_accessor :namebmp #保存头像图片的Hash表
alias initialize_fuki initialize
def initialize
initialize_fuki
# 如果不想使用角色名字直接作为头像文件名
# 可在这里重新设定角色名字与文件名的对应关系
@namebmp ={"玩家"=>"维斯特"}
end
end
#==============================================================================
# ■ Window_InputNumber
#==============================================================================
class Window_InputNumber < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# digits_max : 位数
#--------------------------------------------------------------------------
def initialize(digits_max)
@digits_max = digits_max
@number = 0
# 从数字的幅度计算(假定与 0~9 等幅)光标的幅度
dummy_bitmap = Bitmap.new(MES_FONT_SIZE, MES_FONT_SIZE)
@cursor_width = dummy_bitmap.text_size("0").width + 8
dummy_bitmap.dispose
super(0, 0, @cursor_width * @digits_max + 32, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = MES_FONT_SIZE
self.contents.font.color = FUKI_COLOR
self.z += 9999
self.opacity = 0
@index = 0
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 更新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(@index * @cursor_width-4, 0, @cursor_width, MES_FONT_SIZE + 4)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
s = sprintf("%0*d", @digits_max, @number)
for i in 0...@digits_max
self.contents.draw_text(i * @cursor_width, 0, 24, MES_FONT_SIZE + 4, s[i,1])
end
end
end
#==============================================================================
# □ Window_Message
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化状态
#--------------------------------------------------------------------------
def initialize
super(80, 304, 480, 160)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.color = text_color(0)
self.visible = false
self.z = 9998
@fade_in = false
@fade_out = false
@contents_showing = false
@cursor_width = 0
self.active = false
self.index = -1
@w = 0
@h = 0
@wait = 0
@dx = 0
@dy = 0
$mes_speed = MES_SPEED
#------------------------
# ★ 特殊时期中断标志
#------------------------
@no_term_stop = false
@save_x = 0
@save_y = 0
@old_text_info = []
@show_right = false
@show_name = false
@face_width = 0
end
#--------------------------------------------------------------------------
# ○ 决定窗口尺寸并生成窗口
#--------------------------------------------------------------------------
def refresh_create
unless @no_term_stop
@pic_skin.dispose if @pic_skin != nil
if $game_temp.message_text.include?(":")
if $game_temp.message_text.include?("@r")
@show_right = true
$game_temp.message_text.sub!(/\@r/, "")
end
@show_name = true
$game_temp.message_text = '\c[7]【' + $game_temp.message_text
$game_temp.message_text.sub!(/\:/, '\c[7]】\c[0]')
end
self.contents.clear
self.contents.font.color = normal_color
# 取得窗口尺寸
get_windowsize
w = @w + 40
h = @h * (self.contents.font.size + 4) + 30
h = 64 if h < 64
# 生成呼出窗口
set_fukidasi(self.x, self.y, w, h)
draw_msg_face
create_backbmp
end
# 初始化信息表示使用的变量
@dx = @save_x
@dx += @face_width unless @show_right
@dy = @save_y
@cursor_width = 0
@contents_drawing = true
#update
# 瞬间表示的情况下
if $mes_speed == 0
# 循环信息描绘处理
while $game_temp.message_text != ""
draw_massage
end
draw_opt_text
@contents_showing_end = true
@contents_drawing = false
else
# 一个一个描绘文字
refresh_drawtext
end
end
#--------------------------------------------------------------------------
# ○ 一个一个描绘文字
#--------------------------------------------------------------------------
def refresh_drawtext
if $game_temp.message_text != ""
if @wait > 0
@wait -= 1
elsif @wait == 0
# 描绘处理
draw_massage
@wait = $mes_speed
end
else
draw_opt_text
@contents_showing_end = true
@contents_drawing = false
end
end
#--------------------------------------------------------------------------
# ○ 取得窗口尺寸
#--------------------------------------------------------------------------
def get_windowsize
get_face_width($mes_name)
x = y = 0
@h = @w = 0
@cursor_width = 0
# 有选择项的话,处理字的缩进
if $game_temp.choice_start == 0
x = 16
end
# 有等待显示的文字的情况下
if $game_temp.message_text != nil
text = $game_temp.message_text.clone
# 限制文字处理
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
text.gsub!(/\\\\/) { "\x00" }
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\x01" }
text.gsub!(/\\[Gg]/) { "\x02" }
text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\x03" + $data_skills[$1.to_i].name }
text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\x04" + $data_items[$1.to_i].name }
text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\x05" + $data_weapons[$1.to_i].name }
text.gsub!(/\\[Aa]\[([0-9]+)\]/) { "\x06" + $data_armors[$1.to_i].name }
text.gsub!(/\\[Rr]\[([0-9]+)\]/) { "\x10" + $game_actors[$1.to_i].name }
# c 获取 1 个字 (如果不能取得文字就循环)
while ((c = text.slice!(/./m)) != nil)
if c == "\x00"
c = "\\"
end
if c == "\x01" or c == "\x02"
next
end
if c == "\x03" or c == "\x04" or c == "\x05" or c == "\x06" or c == "\x010"
c = " "
end
if c == "\n"
# y 累加 1
y += 1
# 取得纵横尺寸
@h = y
@w = x > @w ? x : @w
if y >= $game_temp.choice_start
@w = x + MES_FONT_SIZE > @w ? x + MES_FONT_SIZE : @w
end
x = 0
x = MES_FONT_SIZE if y >= $game_temp.choice_start
# 下面的文字
next
end
# x 为要描绘文字的宽度加法运算
x += self.contents.text_size(c).width
end
end
# 输入数值的情况
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@h += 1
x = digits_max * self.contents.font.size + 16
@w = x > @w ? x : @w
end
@w += @face_width
@w = 96 if @w < 96
end
#--------------------------------------------------------------------------
# ○ 描绘信息处理
#--------------------------------------------------------------------------
def draw_massage
# 有等待显示的文字的情况下
if $game_temp.message_text != nil or @old_text_info != nil
text = $game_temp.message_text
#p text
# 限制文字处理
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
text.gsub!(/\\\\/) { "\x00" }
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\x01[#{$1}]" }
text.gsub!(/\\[Gg]/) { "\x02" }
text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\x03[#{$1}]" }
text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\x04[#{$1}]" }
text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\x05[#{$1}]" }
text.gsub!(/\\[Aa]\[([0-9]+)\]/) { "\x06[#{$1}]" }
text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\x07[#{$1}]" }
text.gsub!(/\\[Qq]/) { "\x08" }
text.gsub!(/\\[Ff]\[([0-9]+)\]/) { "\x09[#{$1}]" }
text.gsub!(/\\[Rr]\[([0-9]+)\]/) { "\x10[#{$1}]" }
# c 获取 1 个字
c = text.slice!(/./m)
# 选择项的情况
if @dy >= $game_temp.choice_start
# 处理字的缩进
@dx = MES_FONT_SIZE
@dx += @face_width unless @show_right
@dx += MES_FONT_SIZE if @show_name
# 描绘文字
self.contents.draw_text(@dx, 24 * @dy, 24, 24, c)
# x 为要描绘文字宽度的加法运算
@dx += self.contents.text_size(c).width
# 循环
while ((c = text.slice!(/./m)) != "\n")
# 描绘文字
self.contents.draw_text(@dx, 24 * @dy, 24, 24, c)
# x 为要描绘文字宽度的加法运算
@dx += self.contents.text_size(c).width
end
if c == "\n"
# 更新光标宽度
@cursor_width = [@cursor_width, @dx - @face_width].max
# dy 累加 1
@dy += 1
end
return
end
case c
when "\x00"
c = "\\"
when "\x01"
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
self.contents.font.color = text_color(color)
when "\x02"
@contents_showing_end = true
@contents_drawing = false
terminate_messageX
@save_x = @dx
@save_y = @dy
when "\x03"
text.sub!(/\[([0-9]+)\]/, "")
last_character
draw_icon($data_skills[$1.to_i], 4 + @dx, 24 * @dy)
@dx += self.contents.text_size(" ").width
when "\x04"
text.sub!(/\[([0-9]+)\]/, "")
last_character
draw_icon($data_items[$1.to_i], 4 + @dx, 24 * @dy)
@dx += self.contents.text_size(" ").width
when "\x05"
text.sub!(/\[([0-9]+)\]/, "")
last_character
draw_icon($data_weapons[$1.to_i], 4 + @dx, 24 * @dy)
@dx += self.contents.text_size(" ").width
when "\x06"
text.sub!(/\[([0-9]+)\]/, "")
last_character
draw_icon($data_armors[$1.to_i], 4 + @dx, 24 * @dy)
@dx += self.contents.text_size(" ").width
when "\x07"
text.sub!(/\[([0-9]+)\]/, "")
self.contents.font.color.alpha = $1.to_i
when "\x08"
text.sub!(/\[([0-9]+)\]/, "")
$play_voice = !$play_voice
when "\x09"
text.sub!(/\[([0-9]+)\]/, "")
self.contents.font.name = FONT_ARRAY[$1.to_i]
when "\x10"
text.sub!(/\[([0-9]+)\]/, "")
last_character
draw_actor_graphic($game_actors[$1.to_i], 4 + @dx, 24 * @dy)
@dx += self.contents.text_size(" ").width
when "\n"
@dy += 1
@dx = 0
@dx += @face_width unless @show_right
@dx += MES_FONT_SIZE if @show_name
last_character
else
last_character
size_zy = 6 # 设定文字动态增大幅度
if c != nil
self.contents.font.size = MES_FONT_SIZE
font_size = self.contents.font.size += size_zy
@old_text_info.push(@dx , @dy , font_size, self.contents.font.color.clone, c)
self.contents.draw_text(4 + @dx, (font_size + 4 - size_zy) * @dy - size_zy / 2, font_size, font_size, c)
self.contents.font.size -= size_zy
Audio.se_play("Audio/SE/Voice", 90, 100) if $play_voice and c != " "
@dx += self.contents.text_size(c).width
end
end
end
end
#--------------------------------------------------------------------------
# ○ 完成上一个字符的描绘
#--------------------------------------------------------------------------
def last_character
size_zy = 6 # 设定文字动态增大幅度
unless @old_text_info == []
self.contents.fill_rect (4 + @old_text_info[0], (@old_text_info[2]+ 4 - size_zy) * @old_text_info[1] - size_zy / 2, @old_text_info[2], @old_text_info[2], Color.new(0,0,0,0))
color = self.contents.font.color.clone
self.contents.font.color = @old_text_info[3].clone
self.contents.font.size = @old_text_info[2] -= size_zy
self.contents.draw_text(4 + @old_text_info[0], (@old_text_info[2] + 4) * @old_text_info[1], @old_text_info[2], @old_text_info[2], @old_text_info[4])
self.contents.font.color = color
@old_text_info = []
end
end
#--------------------------------------------------------------------------
# ○ 选择项和输入数值的情况下
#--------------------------------------------------------------------------
def draw_opt_text
# 选择项的情况下
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
end
# 输入数值的情况下
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.number = number
@input_number_window.x = self.x + @face_width + MES_FONT_SIZE + 8
@input_number_window.y = self.y + $game_temp.num_input_start * (MES_FONT_SIZE + 2)
end
end
#--------------------------------------------------------------------------
# ○ 生成背景图片
#--------------------------------------------------------------------------
def create_backbmp
@pic_skin.dispose if @pic_skin != nil
@pic_skin = Sprite.new
@pic_skin.opacity = 0 unless @no_term_stop
@pic_skin.bitmap = Bitmap.new(self.width + 32, self.height + 32)
@pic_skin.x = self.x + 2
@pic_skin.y = self.y + 2
@pic_skin.z = self.z
bitmap = RPG::Cache.windowskin(FUKI_SKIN_NAME)
rect = Rect.new(0, 0, 32, 32)
@pic_skin.bitmap.blt(0, 0, bitmap, rect)
rect = Rect.new(96, 0, 32, 32)
@pic_skin.bitmap.blt(self.width-32, 0, bitmap, rect)
rect = Rect.new(0, 96, 32, 32)
@pic_skin.bitmap.blt(0, self.height-32, bitmap, rect)
rect = Rect.new(96, 96, 32, 32)
@pic_skin.bitmap.blt(self.width-32, self.height-32, bitmap, rect)
rect = Rect.new(0, 32, 32, 32)
@pic_skin.bitmap.stretch_blt(Rect.new(0, 32, 32, self.height - 64), bitmap, rect)
rect = Rect.new(96, 32, 32, 32)
@pic_skin.bitmap.stretch_blt(Rect.new(self.width-32,32,32,self.height-64), bitmap, rect)
rect = Rect.new(32, 0, 32, 32)
@pic_skin.bitmap.stretch_blt(Rect.new(32,0,self.width-64,self.height-32), bitmap, rect)
rect = Rect.new(32, 96, 32, 32)
@pic_skin.bitmap.stretch_blt(Rect.new(32,self.height-32,self.width-64,32), bitmap, rect)
bitmap.dispose
end
#--------------------------------------------------------------------------
# ○ 设置呼出对话框
#--------------------------------------------------------------------------
def set_fukidasi(x, y, width, height)
begin
self.pause = false # 不显示暂停标志
pos = get_fuki_pos(width, height) # 取得对话框位置
x = pos[0]
y = pos[1]
self.windowskin = RPG::Cache.windowskin($game_system.windowskin_name)
self.x = x
self.y = y
self.height = height
self.width = width
unless @no_term_stop
self.contents.dispose
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = FUKI_OPACITY
self.contents.clear
self.contents.font.color = Color.new(0, 100, 0, 255)
self.contents.font.size = MES_FONT_SIZE
end
if $game_system.message_frame == 0
tale_pos = get_tale_pos
@tale = Sprite.new
@tale.bitmap = Bitmap.new(64, 32)
if TAIL_SHOW
case @message_position
when 0 # 上
bitmap = RPG::Cache.windowskin(FUKI_SKIN_NAME)
rect = Rect.new(32, 32, 64, 32)
@tale.bitmap.blt(0, 0, bitmap, rect)
bitmap.dispose
@tale.x = tale_pos[0]
@tale.x += 8 if @tale.x < 64
if @tale.x > 640 - 64
@tale.mirror = true
@tale.x -= 64
end
@tale.y = tale_pos[1]
@tale.z = self.z + 1
when 1 # 中
@tale.dispose
@tale = nil
when 2 # 下
bitmap = RPG::Cache.windowskin(FUKI_SKIN_NAME)
rect = Rect.new(32, 64, 64, 32)
@tale.bitmap.blt(0, 0, bitmap, rect)
bitmap.dispose
@tale.x = tale_pos[0]
@tale.x += 8 if @tale.x < 64
if @tale.x > 640 - 64
@tale.mirror = true
@tale.x -= 64
end
@tale.y = tale_pos[1]
@tale.z = self.z + 1
end
end
end
rescue
del_fukidasi
reset_window(width, height)
end
end
#--------------------------------------------------------------------------
# ○ 计算呼出对话框的位置
#--------------------------------------------------------------------------
def get_fuki_pos(width, height)
# 取得角色
@character = get_character($mes_id)
if @character == nil
# 角色不存在的情况下使用默认信息框
del_fukidasi
reset_window(width, height)
return
end
# 处理坐标
x = (@character.real_x - $game_map.display_x + 64) * 32 / 128 - (width / 2)
# 为尽量显示在画面内而移动横坐标
if x + width > 640
x = 640 - width
elsif x < 0
x = 0
end
# 决定窗口位置
case $game_system.message_position
when 0 # 上
y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 - height - CHARACTOR_HEIGHT + POP_SHIFT_TOP
when 1 # 中
x = (640 - width) / 2
y = (480 - height) / 2
when 2 # 下
y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 + 32 + POP_SHIFT_UNDER
end
# 纪录文章显示位置
@message_position = $game_system.message_position
if POS_FIX
case @message_position
when 0 # 上
if y <= 0
@message_position = 2
y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 + 32 + POP_SHIFT_UNDER
end
when 2 # 下
if y + height >= 480
@message_position = 0
y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 - height - CHARACTOR_HEIGHT + POP_SHIFT_TOP
end
end
end
return [x, y]
end
#--------------------------------------------------------------------------
# ○ 计算尾部图标的位置
#--------------------------------------------------------------------------
def get_tale_pos
case @message_position
when 0 # 上
# 处理坐标
x = ( @character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 8
y = self.y + self.height - 6
when 1 # 中
x = nil
y = nil
when 2 # 下
# 处理坐标
x = ( @character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 8
y = self.y - 18
end
return [x, y]
end
#--------------------------------------------------------------------------
# ○ 设置角色半身像窗口
#--------------------------------------------------------------------------
def draw_msg_face
@face_sprite.dispose if @face_sprite != nil
# $mes_name为空时不显示
if $mes_name == nil or $mes_name == ""
return
else
# 设定变量
mes_name = $mes_name
if $game_temp.namebmp[mes_name] == nil
sFile = FACE_PIC_DIR + mes_name
else
sFile = FACE_PIC_DIR + $game_temp.namebmp[mes_name]
end
bitmap = Bitmap.new(sFile)
@pic_width = bitmap.width
@pic_height = bitmap.height
@face_sprite = Sprite.new
@face_sprite.x = self.x + 26
@face_sprite.x = self.x + self.width - @pic_width - 26 if @show_right
@face_sprite.y = self.y + self.height - @pic_height - 6
@face_sprite.bitmap = bitmap
@face_sprite.z = self.z + 3
@face_sprite.mirror = @show_right
@face_sprite.opacity = 0
end
end
#--------------------------------------------------------------------------
# ○ 释放呼出对话框
#--------------------------------------------------------------------------
def del_fukidasi
if @tale != nil
@tale.dispose
@tale = nil
end
self.opacity = 0
self.x = 80
self.width = 480
self.height = 160
self.contents.dispose
self.contents = Bitmap.new(width - 32, height - 32)
self.pause = true
end
#--------------------------------------------------------------------------
# ○ 取得角色
# parameter : 参数
#--------------------------------------------------------------------------
def get_character(parameter)
# 参数分歧
case parameter
when nil
return events == nil
when -1 # 玩家
return $game_player
when 0 # 该事件
events = $game_map.events
return events == nil ? nil : events[$active_event_id]
else # 特定事件
events = $game_map.events
return events == nil ? nil : events[parameter]
end
end
#--------------------------------------------------------------------------
# ● 设定窗口位置和不透明度
#--------------------------------------------------------------------------
def reset_window(width = nil, height = nil)
if $game_temp.in_battle
self.y = 16
else
case $game_system.message_position
when 0 # 上
self.y = 16
when 1 # 中
if height != nil and width != nil
self.y = (480 - height) / 2 - 32
self.x = (640 - width) / 2
self.width = width
self.height = height
self.contents.dispose
self.contents = Bitmap.new(width - 32, height - 32)
else
self.y = 160
end
when 2 # 下
self.y = 304
end
end
self.opacity = 0
self.back_opacity = MES_OPACITY
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
update_fuki # 呼出模式下跟随事件移动
if @fade_in # 渐变的情况下
self.contents_opacity += 24
@pic_skin.opacity += 20
if @tale != nil
@face_sprite.opacity += 24 if @face_sprite != nil and !@face_sprite.disposed?
@tale.opacity += 20
end
@input_number_window.contents_opacity += 24 if @input_number_window != nil
@fade_in = false if self.contents_opacity == 255
return
end
if @contents_drawing # 显示信息中的情况下
refresh_drawtext
return
end
update_input_number_window # 输入数值的情况下
if @contents_showing_end # 显示信息结束的情况下
if $game_temp.choice_max == 0 and @tale == nil
self.pause = true
else
self.pause = false
end
update_choose
return
end
if @fade_out == false and $game_temp.message_text != nil # 在渐变以外的状态下
@contents_showing = true
$game_temp.message_window_showing = true
reset_window
refresh_create
if @no_term_stop
self.visible = true
else
@tale.opacity = 0 if @tale != nil
Graphics.frame_reset
self.visible = true
self.contents_opacity = 0
@input_number_window.contents_opacity = 0 if @input_number_window != nil
@fade_in = true
end
return
end
unless @no_term_stop # 没有可以显示的信息、但是窗口为可见的情况下
if self.visible
@fade_out = true
self.opacity -= 48
@face_sprite.opacity -= 48 if @face_sprite != nil and !@face_sprite.disposed?
@pic_skin.opacity -= 48 if @pic_skin != nil and !@pic_skin.disposed?
@tale.opacity -= 48 if @tale != nil and
[email protected]
?
if (@face_sprite == nil) or @face_sprite.disposed? or (@face_sprite.opacity == 0)
self.visible = false
@face_sprite.dispose if @face_sprite != nil
@pic_skin.dispose
@fade_out = false
$game_temp.message_window_showing = false
del_fukidasi
end
return
end
else
$game_temp.message_window_showing = false
end
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
terminate_message
$game_temp.message_window_showing = false
@input_number_window.dispose if @input_number_window != nil
super
end
#--------------------------------------------------------------------------
# ● 信息结束处理
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
self.contents.clear
# 清除显示中标志
@contents_showing = false
@contents_showing_end = false
$mes_name = ""
# 呼叫信息调用
$game_temp.message_proc.call if $game_temp.message_proc != nil
# 清除文章、选择项、输入数值的相关变量
$game_temp.message_text = nil
$game_temp.message_proc = nil
$game_temp.choice_start = 99
$game_temp.choice_max = 0
$game_temp.choice_cancel_type = 0
$game_temp.choice_proc = nil
$game_temp.num_input_start = 99
$game_temp.num_input_variable_id = 0
$game_temp.num_input_digits_max = 0
# 释放金钱窗口
if @gold_window != nil
@gold_window.dispose
@gold_window = nil
end
@no_term_stop = false
@save_x = 0
@save_y = 0
@show_right = false
@show_name = false
@face_width = 0
end
#--------------------------------------------------------------------------
# ● ★信息结束处理★
#--------------------------------------------------------------------------
def terminate_messageX
self.active = false
self.pause = false
self.index = -1
# 清除显示中标志
@contents_showing = false
@contents_showing_end = false
# 呼叫信息调用
$game_temp.message_proc.call if $game_temp.message_proc != nil
# 清除文章、选择项、输入数值的相关变量
$game_temp.message_text = nil
$game_temp.message_proc = nil
@no_term_stop = true
@show_right = false
@show_name = false
@face_width = 0
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index >= 0
n = $game_temp.choice_start + @index
self.cursor_rect.set(MES_FONT_SIZE / 2, n * (MES_FONT_SIZE + 4), @cursor_width, MES_FONT_SIZE + 4)
self.cursor_rect.x += @face_width unless @show_right
self.cursor_rect.x += MES_FONT_SIZE / 2 if @show_name
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# ● 获取文字颜色色
# n : 文字颜色编号 (0~31)
#--------------------------------------------------------------------------
def text_color(n)
return normal_color if n > 31
x = (n % 8) * 16
y = 128 + (n / 8) * 16
return RPG::Cache.windowskin(FUKI_SKIN_NAME).get_pixel(x, y)
end
#--------------------------------------------------------------------------
# ● 取得普通文字色
#--------------------------------------------------------------------------
def normal_color
nil_color = Color.new(0,100,0,255)
return FUKI_COLOR if FUKI_COLOR != nil_color
return nil_color
end
#--------------------------------------------------------------------------
# ● 获取头像宽度
#--------------------------------------------------------------------------
def get_face_width(face_name)
return if $mes_name == ""
filename = FACE_PIC_DIR + face_name
bitmap = Bitmap.new(filename)
@face_width = bitmap.width + MES_FONT_SIZE
bitmap.dispose
end
#--------------------------------------------------------------------------
# ● 描绘物品
# item : 物品
#--------------------------------------------------------------------------
def draw_icon(item, x, y)
return if item == nil
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x + 4, y, bitmap, Rect.new(0, 0, 24, 24))
color = self.contents.font.color.clone
self.contents.font.color = text_color(1)
self.contents.draw_text(x + 28, y, self.contents.text_size(item.name).width + 5, 24, item.name)
self.contents.font.color = color
@dx += self.contents.text_size(item.name).width
end
#--------------------------------------------------------------------------
# ● 图形的描绘
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x, y - 4, bitmap, src_rect)
color = self.contents.font.color.clone
self.contents.font.color = text_color(1)
self.contents.draw_text(x + 32, y, self.contents.text_size(actor.name).width + 5, 24, actor.name)
self.contents.font.color = color
@dx += self.contents.text_size(actor.name).width
end
#--------------------------------------------------------------------------
# ● 刷新呼出对话框
#--------------------------------------------------------------------------
def update_fuki
if @tale != nil
pos = get_fuki_pos(self.width, self.height)
self.x = pos[0]
self.y = pos[1]
tale_pos = get_tale_pos
@tale.mirror = false
@tale.x = tale_pos[0]
@tale.x += 8 if @tale.x < 64
if @tale.x > 640 - 64
@tale.mirror = true
@tale.x -= 64
end
@tale.y = tale_pos[1]
@pic_skin.x = self.x + 2
@pic_skin.y = self.y + 2
if @face_sprite != nil and !@face_sprite.disposed?
@face_sprite.x = self.x + 26
@face_sprite.x = self.x + self.width - @pic_width - 26 if @show_right
@face_sprite.y = self.y + self.height - @pic_height - 6
end
end
end
#--------------------------------------------------------------------------
# ● 刷新数字输入框
#--------------------------------------------------------------------------
def update_input_number_window
if @input_number_window != nil
@input_number_window.update
# 确定
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_variables[$game_temp.num_input_variable_id] = @input_number_window.number
# 释放输入数值窗口
@input_number_window.dispose
@input_number_window = nil
$game_map.need_refresh = true
terminate_message
del_fukidasi
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新选择输入
#--------------------------------------------------------------------------
def update_choose
if Input.trigger?(Input::B)
if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
$game_system.se_play($data_system.cancel_se)
$game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
terminate_message
del_fukidasi
end
end
if Input.trigger?(Input::C)
if $game_temp.choice_max > 0
$game_system.se_play($data_system.decision_se)
$game_temp.choice_proc.call(self.index)
end
terminate_message
del_fukidasi
end
end
end
复制代码
事件内容:
脚本:$mes_id = 1 #对话框出现在1号事件头顶
$mes_name = " " #引号里输入你的图片名字
文章:你好啊。我是XXX
这样就行了。另外 文章:@or 你好啊。我是XXX #加上@or 图片显示在右边
作者:
爆焰
时间:
2012-8-1 14:39
显示图片,对话,再取消图片即可
作者:
心倾河中
时间:
2012-8-1 15:47
爆焰 发表于 2012-8-1 14:39
显示图片,对话,再取消图片即可
······加我q,详说吧,我没弄明白,本人纯新手
‘‘──心倾河中于2012-8-1 15:48补充以下内容:
······加我q,详说吧,我没弄明白,本人纯新手
’’
作者:
woyaozhuce
时间:
2012-8-1 17:52
这。。。你不是QQ说吧最佳给我么。我了个去
简直是坑爹啊~~~~~~~~
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1