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

Project1

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

求助!关于多个动画播放。

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
61 小时
注册时间
2008-8-18
帖子
45
跳转到指定楼层
1
发表于 2009-1-26 14:25:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
因游戏需要使用了柳柳大人制作的多个动画同时播放,覆盖了原来的Sprite_Base,但是发现还是只能播放1个,
先播放的动画被后来的动画给取消了。

请各位老大帮忙解决一下。


游戏使用了 :开头画面特效,地图作为战斗背景,更改窗口外观,国外的截图存档,
SV横版2.7汉化版,升级手动加点,物品分类,以及升级提示脚本。

  1. #==============================================================================
  2. # ■ Sprite_Base
  3. #------------------------------------------------------------------------------
  4. #  处理动画显示追加活动块的类变量。
  5. #==============================================================================

  6. class Sprite_Base < Sprite
  7.   #--------------------------------------------------------------------------
  8.   # ● 类变量
  9.   # @@animations 用来记录动画正在播放,防止同一时间多次在同位置播放全屏动画
  10.   # @@_reference_count 用来记录哪些素材正在被使用
  11.   #--------------------------------------------------------------------------
  12.   @@animations = []
  13.   @@_reference_count = {}
  14.   #--------------------------------------------------------------------------
  15.   # ● done 初始化对像
  16.   #     viewport : 视口
  17.   #--------------------------------------------------------------------------
  18.   def initialize(viewport = nil)
  19.     super(viewport)
  20.     @use_sprite = true          # 活动块使用标记
  21.     @animation_duration = 0     # 动画剩余时间
  22.     # 基本结构:animation, mirror, length, sprites, ox, oy ,[bitmap1, bitmap2]
  23.     @animation_collection = []
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● done 释放
  27.   #--------------------------------------------------------------------------
  28.   def dispose
  29.     super
  30.     return if @animation_collection == nil
  31.     for ani in @animation_collection
  32.       dispose_animation(ani)
  33.     end
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● done 刷新画面
  37.   #--------------------------------------------------------------------------
  38.   def update
  39.     super
  40.     if @animation_collection != nil
  41.       @animation_duration -= 1
  42.       for ani in @animation_collection
  43.         ani[2] -= 1
  44.         if ani[2] % 4 == 0
  45.           update_animation(ani)
  46.         end
  47.       end
  48.     end
  49.     @@animations.clear
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● done 动画显示中判定
  53.   #--------------------------------------------------------------------------
  54.   def animation?
  55.     return @animation_collection != nil
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● done 开始动画
  59.   #--------------------------------------------------------------------------
  60.   def start_animation(animation, mirror = false)
  61.     @animation = animation
  62.     return if @animation == nil
  63.     @animation_mirror = mirror
  64.     animation_length = @animation.frame_max * 4 + 1
  65.     @animation_duration += animation_length
  66.     animbitmap = load_animation_bitmap
  67.     @animation_sprites = []
  68.     if @animation.position != 3 or not @@animations.include?(animation)
  69.       if @use_sprite
  70.         for i in 0..15
  71.           sprite = ::Sprite.new(viewport)
  72.           sprite.visible = false
  73.           @animation_sprites.push(sprite)
  74.         end
  75.         unless @@animations.include?(animation)
  76.           @@animations.push(animation)
  77.         end
  78.       end
  79.     end
  80.     if @animation.position == 3
  81.       if viewport == nil
  82.         @animation_ox = 544 / 2
  83.         @animation_oy = 416 / 2
  84.       else
  85.         @animation_ox = viewport.rect.width / 2
  86.         @animation_oy = viewport.rect.height / 2
  87.       end
  88.     else
  89.       @animation_ox = x - ox + width / 2
  90.       @animation_oy = y - oy + height / 2
  91.       if @animation.position == 0
  92.         @animation_oy -= height / 2
  93.       elsif @animation.position == 2
  94.         @animation_oy += height / 2
  95.       end
  96.     end
  97.     @animation_collection.push([@animation, @animation_mirror, animation_length,
  98.                                 @animation_sprites, @animation_ox, @animation_oy,
  99.                                 animbitmap])
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ● done 读取动画的类变量
  103.   #--------------------------------------------------------------------------
  104.   def load_animation_bitmap
  105.     animation1_name = @animation.animation1_name
  106.     animation1_hue = @animation.animation1_hue
  107.     animation2_name = @animation.animation2_name

  108.     animation2_hue = @animation.animation2_hue
  109.     @animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  110.     @animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  111.     if @@_reference_count.include?(@animation_bitmap1)
  112.       @@_reference_count[@animation_bitmap1] += 1
  113.     else
  114.       @@_reference_count[@animation_bitmap1] = 1
  115.     end
  116.     if @@_reference_count.include?(@animation_bitmap2)
  117.       @@_reference_count[@animation_bitmap2] += 1
  118.     else
  119.       @@_reference_count[@animation_bitmap2] = 1
  120.     end
  121.     Graphics.frame_reset
  122.     return [@animation_bitmap1, @animation_bitmap2]
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● done 释放动画
  126.   #--------------------------------------------------------------------------
  127.   def dispose_animation(ani)
  128.     if ani[6][0] != nil
  129.       @@_reference_count[ani[6][0]] -= 1
  130.       if @@_reference_count[ani[6][0]] == 0
  131.         ani[6][0].dispose
  132.       end
  133.     end
  134.     if ani[6][1] != nil
  135.       @@_reference_count[ani[6][1]] -= 1
  136.       if @@_reference_count[ani[6][1]] == 0
  137.         ani[6][1].dispose
  138.       end
  139.     end
  140.     if ani[3] != nil
  141.       for sprite in ani[3]
  142.         sprite.dispose
  143.       end
  144.       @animation_sprites = nil
  145.       @animation = nil
  146.     end
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● done 刷新动画
  150.   #--------------------------------------------------------------------------
  151.   def update_animation(ani)
  152.     if ani[2] > 0
  153.       frame_index = ani[0].frame_max - (ani[2] + 3) / 4
  154.       animation_set_sprites(ani[0].frames[frame_index], ani)
  155.       for timing in ani[0].timings
  156.         if timing.frame == frame_index
  157.           animation_process_timing(timing)
  158.         end
  159.       end
  160.     else
  161.       dispose_animation(ani)
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● done 设置动画活动块
  166.   #     frame : 帧数据 (RPG::Animation::Frame)
  167.   #--------------------------------------------------------------------------
  168.   def animation_set_sprites(frame, ani)
  169.     cell_data = frame.cell_data
  170.     for i in 0..15
  171.       sprite = ani[3][i]
  172.       next if sprite == nil
  173.       pattern = cell_data[i, 0]
  174.       if pattern == nil or pattern == -1
  175.         sprite.visible = false
  176.         next
  177.       end
  178.       if pattern < 100
  179.         sprite.bitmap = ani[6][0]
  180.       else
  181.         sprite.bitmap = ani[6][1]
  182.       end
  183.       sprite.visible = true
  184.       sprite.src_rect.set(pattern % 5 * 192,
  185.         pattern % 100 / 5 * 192, 192, 192)
  186.       if @animation_mirror
  187.         sprite.x = ani[4] - cell_data[i, 1]
  188.         sprite.y = ani[5] - cell_data[i, 2]
  189.         sprite.angle = (360 - cell_data[i, 4])
  190.         sprite.mirror = (cell_data[i, 5] == 0)
  191.       else
  192.         sprite.x = ani[4] + cell_data[i, 1]
  193.         sprite.y = ani[5] + cell_data[i, 2]
  194.         sprite.angle = cell_data[i, 4]
  195.         sprite.mirror = (cell_data[i, 5] == 1)
  196.       end
  197.       sprite.z = self.z + 300
  198.       sprite.ox = 96
  199.       sprite.oy = 96
  200.       sprite.zoom_x = cell_data[i, 3] / 100.0
  201.       sprite.zoom_y = cell_data[i, 3] / 100.0
  202.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  203.       sprite.blend_type = cell_data[i, 7]
  204.     end
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # ●  done SE 与闪烁的时机处理
  208.   #     timing : Timing数据 (RPG::Animation::Timing)
  209.   #--------------------------------------------------------------------------
  210.   def animation_process_timing(timing)
  211.     timing.se.play
  212.     case timing.flash_scope
  213.     when 1
  214.       self.flash(timing.flash_color, timing.flash_duration * 4)
  215.     when 2
  216.       if viewport != nil
  217.         viewport.flash(timing.flash_color, timing.flash_duration * 4)
  218.       end
  219.     when 3
  220.       self.flash(nil, timing.flash_duration * 4)
  221.     end
  222.   end
  223. end
复制代码

#以上是柳柳大人的脚本。
此贴于 2009-2-1 22:06:40 被版主木葬枫提醒,请楼主看到后对本贴做出回应。
此贴于 2009-2-4 11:18:33 被版主木葬枫提醒,请楼主看到后对本贴做出回应。
魔都3修改中....
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-6-15 17:58

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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