| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2014-6-28 |
| 在线时间 | 276 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 276 小时
- 注册时间
- 2012-9-27
- 回帖
- 164

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 北极七月熊 于 2013-4-19 17:37 编辑
呃……这个只是根据Window_Message修改了一下。
效果比较简单。
只要在头像的文件名加上相应后缀,然后在事件显示文字中添加头像就可以了。
设定了两种动画效果:
文件名后缀+"_a"为循环播放,这个可以用来做眨眼说话等表情
文件名后缀+"_b"为播放一次,停止在最后一帧,其实同时也能当做静态表情。
而 如果没有加后缀,就按系统默认的静态头像显示。
动态头像的宽度和高度可以在代码里重新设定,宽度要填写单帧的宽度,总宽度不限。
范例下载地址:
http://pan.baidu.com/share/link?shareid=410675&uk=975966104
[pre lang="ruby" line="1"]#==============================================================================
# ■ 动态头像(修改Window_Message)by 只有金刚心
#------------------------------------------------------------------------------
# 使用方法:在文件名加上相应后缀,然后在事件显示文字中添加头像就可以了
# 文件名后缀+"_a"为循环播放
# 文件名后缀+"_b"为播放一次,停止在最后一帧
# 如果没有加后缀,就按系统默认的静态头像显示
# 动态头像的宽度和高度可以再28-29行重新设定
#==============================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, window_height)
self.z = 200
self.openness = 0
create_all_windows
create_back_bitmap
create_back_sprite
clear_instance_variables
#★★动态头像定义★★
@face_index = 0
@face_ani_speed = 8 #动态头像播放速度
@face_width = 96 #头像的单帧宽度
@face_height = 96 #头像的高度
@face_bitmap = Sprite.new
@face_bitmap.bitmap = Bitmap.new(@face_width,@face_height)
@face_bitmap.z = 10000
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
super
dispose_all_windows
dispose_back_bitmap
dispose_back_sprite
#★★释放头像★★
@face_bitmap.dispose
@face_bitmap.bitmap.dispose
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_all_windows
update_back_sprite
update_fiber
#★★动态头像播放计数★★
@face_index += 1
#★★判断是否为动态头像★★
if $game_message.face_name =~ /[a-zA-Z0-9]_a/ or $game_message.face_name =~ /[a-zA-Z0-9]_b/
update_face
end
end
#--------------------------------------------------------------------------
# ★★ 动态头像 ★★
#--------------------------------------------------------------------------
#★★绘制/更新头像★★
def update_face
@bitmap = Cache.face($game_message.face_name)
@face_index_max = @bitmap.width/@face_width - 1
@face_bitmap.bitmap.clear
#文件名后缀+"_a"为循环播放
if $game_message.face_name =~ /[a-zA-Z0-9]_a/
rect = Rect.new(@face_index / @face_ani_speed % @face_index_max * @face_width,0,@face_width,@face_height)
#文件名后缀+"_b"为播放一次,停止在最后一帧
elsif $game_message.face_name =~ /[a-zA-Z0-9]_b/
if (@face_index /@face_ani_speed) < @face_index_max
rect = Rect.new(@face_index /@face_ani_speed * @face_width,0,@face_width,@face_height)
else
rect = Rect.new(@face_index_max * @face_width,0,@face_width,@face_height)
end
#文件名不加后缀则为系统默认的静态头像★宽度高度未重新设置★
else
rect = Rect.new($game_message.face_index % 4 * 96 , $game_message.face_index / 4 * 96, 96,96)
end
@face_bitmap.bitmap.blt(0,0, @bitmap,rect)
end
#--------------------------------------------------------------------------
# ● 处理纤程的主逻辑
#--------------------------------------------------------------------------
def fiber_main
$game_message.visible = true
update_background
update_placement
loop do
process_all_text if $game_message.has_text?
process_input
#★★清除头像★★
@face_bitmap.bitmap.clear
$game_message.clear
@gold_window.close
Fiber.yield
break unless text_continue?
end
close_and_wait
$game_message.visible = false
@fiber = nil
end
#--------------------------------------------------------------------------
# ● 更新窗口的位置
#--------------------------------------------------------------------------
def update_placement
@position = $game_message.position
self.y = @position * (Graphics.height - height) / 2
#★★更新头像的坐标★★
face_y = @position * (Graphics.height - height) / 2 + 12
@face_bitmap.y = face_y
@face_bitmap.x = 12
@gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height
end
#--------------------------------------------------------------------------
# ● 翻页处理
#--------------------------------------------------------------------------
def new_page(text, pos)
contents.clear
#★★载入头像以及重新计数★★
update_face
@face_index = 0
#draw_face($game_message.face_name, $game_message.face_index, 0, 0)
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
#--------------------------------------------------------------------------
# ● 获取换行位置
#--------------------------------------------------------------------------
def new_line_x
#★★修正换行位置★★
if $game_message.face_name.empty?
return 0
elsif $game_message.face_name =~ /[a-zA-Z0-9]_a/ or $game_message.face_name =~ /[a-zA-Z0-9]_b/
return 112 + @face_width - 96
else
return 112
end
end
end
[/pre] |
评分
-
查看全部评分
|