设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 5458|回复: 7
打印 上一主题 下一主题

[RMVA发布] RMVA-动态头像,制作眨眼说话表情等

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
276 小时
注册时间
2012-9-27
帖子
182

短篇八橙光组亚军

跳转到指定楼层
1
发表于 2013-4-19 17:28:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 北极七月熊 于 2013-4-19 17:37 编辑

呃……这个只是根据Window_Message修改了一下。
效果比较简单。
只要在头像的文件名加上相应后缀,然后在事件显示文字中添加头像就可以了。
设定了两种动画效果:
文件名后缀+"_a"为循环播放,这个可以用来做眨眼说话等表情
文件名后缀+"_b"为播放一次,停止在最后一帧,其实同时也能当做静态表情。
而 如果没有加后缀,就按系统默认的静态头像显示。
动态头像的宽度和高度可以在代码里重新设定,宽度要填写单帧的宽度,总宽度不限。


范例下载地址:
http://pan.baidu.com/share/link?shareid=410675&uk=975966104

RUBY 代码复制
  1. #==============================================================================
  2. # ■ 动态头像(修改Window_Message)by 只有金刚心
  3. #------------------------------------------------------------------------------
  4. # 使用方法:在文件名加上相应后缀,然后在事件显示文字中添加头像就可以了
  5. # 文件名后缀+"_a"为循环播放
  6. # 文件名后缀+"_b"为播放一次,停止在最后一帧
  7. # 如果没有加后缀,就按系统默认的静态头像显示
  8. # 动态头像的宽度和高度可以再28-29行重新设定
  9. #==============================================================================
  10.  
  11. class Window_Message < Window_Base
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化对象
  14.   #--------------------------------------------------------------------------
  15.   def initialize
  16.     super(0, 0, window_width, window_height)
  17.     self.z = 200
  18.     self.openness = 0
  19.     create_all_windows
  20.     create_back_bitmap
  21.     create_back_sprite
  22.     clear_instance_variables
  23.  
  24.     #★★动态头像定义★★
  25.     @face_index = 0
  26.     @face_ani_speed = 8 #动态头像播放速度
  27.     @face_width = 96 #头像的单帧宽度
  28.     @face_height = 96 #头像的高度
  29.     @face_bitmap = Sprite.new
  30.     @face_bitmap.bitmap = Bitmap.new(@face_width,@face_height)
  31.     @face_bitmap.z = 10000
  32.  
  33.   end
  34.  
  35.   #--------------------------------------------------------------------------
  36.   # ● 释放
  37.   #--------------------------------------------------------------------------
  38.   def dispose
  39.     super
  40.     dispose_all_windows
  41.     dispose_back_bitmap
  42.     dispose_back_sprite
  43.  
  44.     #★★释放头像★★
  45.     @face_bitmap.dispose
  46.     @face_bitmap.bitmap.dispose
  47.  
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 更新画面
  51.   #--------------------------------------------------------------------------
  52.   def update
  53.     super
  54.     update_all_windows
  55.     update_back_sprite
  56.     update_fiber
  57.  
  58.     #★★动态头像播放计数★★
  59.     @face_index += 1
  60.  
  61.     #★★判断是否为动态头像★★
  62.     if $game_message.face_name =~ /[a-zA-Z0-9]_a/ or $game_message.face_name =~ /[a-zA-Z0-9]_b/
  63.     update_face
  64.     end
  65.  
  66.   end
  67.  
  68.   #--------------------------------------------------------------------------
  69.   # ★★ 动态头像 ★★
  70.   #--------------------------------------------------------------------------
  71.  
  72.   #★★绘制/更新头像★★
  73.   def update_face
  74.     @bitmap = Cache.face($game_message.face_name)
  75.     @face_index_max = @bitmap.width/@face_width - 1
  76.     @face_bitmap.bitmap.clear
  77.     #文件名后缀+"_a"为循环播放
  78.     if $game_message.face_name =~ /[a-zA-Z0-9]_a/  
  79.       rect = Rect.new(@face_index / @face_ani_speed % @face_index_max * @face_width,0,@face_width,@face_height)
  80.     #文件名后缀+"_b"为播放一次,停止在最后一帧
  81.     elsif $game_message.face_name =~ /[a-zA-Z0-9]_b/
  82.       if (@face_index /@face_ani_speed) <  @face_index_max
  83.         rect = Rect.new(@face_index /@face_ani_speed * @face_width,0,@face_width,@face_height)
  84.       else
  85.         rect = Rect.new(@face_index_max * @face_width,0,@face_width,@face_height)
  86.       end
  87.     #文件名不加后缀则为系统默认的静态头像★宽度高度未重新设置★
  88.     else
  89.     rect = Rect.new($game_message.face_index % 4 * 96 , $game_message.face_index / 4 * 96, 96,96)
  90.     end
  91.     @face_bitmap.bitmap.blt(0,0, @bitmap,rect)
  92.   end
  93.  
  94.  
  95.   #--------------------------------------------------------------------------
  96.   # ● 处理纤程的主逻辑
  97.   #--------------------------------------------------------------------------
  98.   def fiber_main   
  99.     $game_message.visible = true
  100.     update_background
  101.     update_placement
  102.     loop do
  103.       process_all_text if $game_message.has_text?
  104.       process_input
  105.  
  106.       #★★清除头像★★
  107.       @face_bitmap.bitmap.clear
  108.  
  109.       $game_message.clear
  110.       @gold_window.close
  111.       Fiber.yield
  112.       break unless text_continue?
  113.     end
  114.     close_and_wait
  115.     $game_message.visible = false
  116.     @fiber = nil
  117.  
  118.   end
  119.  
  120.   #--------------------------------------------------------------------------
  121.   # ● 更新窗口的位置
  122.   #--------------------------------------------------------------------------
  123.   def update_placement
  124.     @position = $game_message.position
  125.     self.y = @position * (Graphics.height - height) / 2
  126.  
  127.     #★★更新头像的坐标★★
  128.     face_y = @position * (Graphics.height - height) / 2 + 12
  129.     @face_bitmap.y = face_y
  130.     @face_bitmap.x = 12
  131.     @gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height
  132.  
  133.   end
  134.  
  135.   #--------------------------------------------------------------------------
  136.   # ● 翻页处理
  137.   #--------------------------------------------------------------------------
  138.   def new_page(text, pos)
  139.     contents.clear
  140.  
  141.     #★★载入头像以及重新计数★★
  142.     update_face
  143.     @face_index = 0
  144.     #draw_face($game_message.face_name, $game_message.face_index, 0, 0)
  145.  
  146.     reset_font_settings
  147.     pos[:x] = new_line_x
  148.     pos[:y] = 0
  149.     pos[:new_x] = new_line_x
  150.     pos[:height] = calc_line_height(text)
  151.     clear_flags
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ● 获取换行位置
  155.   #--------------------------------------------------------------------------
  156.   def new_line_x
  157.  
  158.     #★★修正换行位置★★
  159.     if $game_message.face_name.empty?
  160.     return 0
  161.     elsif $game_message.face_name =~ /[a-zA-Z0-9]_a/ or $game_message.face_name =~ /[a-zA-Z0-9]_b/
  162.     return 112 + @face_width - 96
  163.     else
  164.     return 112
  165.     end
  166.  
  167.   end
  168.  
  169. end

评分

参与人数 2星屑 +12 收起 理由
0newing + 7 GOOD!
只是逛逛 + 5 第一次评分&amp;奖励

查看全部评分

Lv1.梦旅人

梦石
0
星屑
50
在线时间
432 小时
注册时间
2012-7-7
帖子
379
2
发表于 2013-4-21 00:31:24 | 只看该作者
{:2_258:}一卡一卡的。。

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
276 小时
注册时间
2012-9-27
帖子
182

短篇八橙光组亚军

3
 楼主| 发表于 2013-4-21 10:23:21 | 只看该作者
514578363 发表于 2013-4-21 00:31
一卡一卡的。。

囧,什么意思?
如果是播放速度的话,那是可以调整的……

点评

看起来就动态都有点卡  发表于 2013-4-21 12:33
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
276 小时
注册时间
2012-9-27
帖子
182

短篇八橙光组亚军

4
 楼主| 发表于 2013-4-21 13:20:41 | 只看该作者
本帖最后由 北极七月熊 于 2013-4-21 13:22 编辑


@514578363
那是动画的帧数不够,或者设置不合理~
请去参照别人的动画是如何做的,只有关键帧的话,看起来确实不流畅的~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
30 小时
注册时间
2013-3-10
帖子
11
5
发表于 2013-5-6 09:52:35 | 只看该作者
本帖最后由 潇灵可 于 2013-5-6 12:12 编辑

求用这个脚本和对话框脚本有冲突http://rpg.blue/thread-240977-1-1.html
在么?求合并一下那个脚本,这两个脚本同时用的话,头像会有两个
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
30 小时
注册时间
2013-3-10
帖子
11
6
发表于 2013-5-6 11:58:34 | 只看该作者
本帖最后由 潇灵可 于 2013-5-6 12:12 编辑

求用这个脚本和对话框脚本有冲突http://rpg.blue/thread-240977-1-1.html
在么?求合并一下那个脚本,这两个脚本同时用的话,头像会有两个
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
155
在线时间
1 小时
注册时间
2013-5-8
帖子
3
7
发表于 2013-5-8 14:24:39 | 只看该作者
太废美工了。。这个功能
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
250 小时
注册时间
2011-8-16
帖子
178
8
发表于 2013-8-12 05:14:53 | 只看该作者
哈哈  泽洋舒服多了
——————
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-20 10:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表