| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 3 |
| 经验 | |
| 最后登录 | 2022-10-15 |
| 在线时间 | 286 小时 |
- 梦石
- 0
- 星屑
- 265
- 在线时间
- 286 小时
- 注册时间
- 2009-11-7
- 回帖
- 39

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 Kimu 于 2011-8-27 14:02 编辑
本来一个事件显示动画没显示完再显示另一个动画 前一个动画就会中断 XP有可以叠加多个动画的脚本 求个VX版的
这是XP版的- #--------------------------------------------------
- # 此脚本来自[url]www.66RPG.com[/url],使用请保留此信息
- #--------------------------------------------------
- module RPG
- class Sprite < ::Sprite
- def initialize(viewport = nil)
- super(viewport)
- @_whiten_duration = 0
- @_appear_duration = 0
- @_escape_duration = 0
- @_collapse_duration = 0
- @_damage_duration = 0
- @_animation_duration = 0
- @_blink = false
- @_animation = []
- end
- def animation(animation, hit)
- return if animation == nil
- num = @_animation.size
- @_animation.push([animation, hit, animation.frame_max, []])
- bitmap = RPG::Cache.animation(animation.animation_name,
- animation.animation_hue)
- if @@_reference_count.include?(bitmap)
- @@_reference_count[bitmap] += 1
- else
- @@_reference_count[bitmap] = 1
- end
- if @_animation[num][0] != 3 or not @@_animations.include?(animation)
- for i in 0..15
- sprite = ::Sprite.new
- sprite.bitmap = bitmap
- sprite.visible = false
- @_animation[num][3].push(sprite)
- end
- unless @@_animations.include?(animation)
- @@_animations.push(animation)
- end
- end
- update_animation(@_animation[num])
- end
- def loop_animation(animation)
- return if animation == @_loop_animation
- dispose_loop_animation
- @_loop_animation = animation
- return if @_loop_animation == nil
- @_loop_animation_index = 0
- animation_name = @_loop_animation.animation_name
- animation_hue = @_loop_animation.animation_hue
- bitmap = RPG::Cache.animation(animation_name, animation_hue)
- if @@_reference_count.include?(bitmap)
- @@_reference_count[bitmap] += 1
- else
- @@_reference_count[bitmap] = 1
- end
- @_loop_animation_sprites = []
- for i in 0..15
- sprite = ::Sprite.new
- sprite.bitmap = bitmap
- sprite.visible = false
- @_loop_animation_sprites.push(sprite)
- end
- # update_loop_animation
- end
- def dispose_animation
- for anime in @_animation.reverse
- sprite = anime[3][0]
- if sprite != nil
- @@_reference_count[sprite.bitmap] -= 1
- if @@_reference_count[sprite.bitmap] == 0
- sprite.bitmap.dispose
- end
- end
- for sprite in anime[3]
- sprite.dispose
- end
- @_animation.delete(anime)
- end
- end
-
- def update
- super
- if @_whiten_duration > 0
- @_whiten_duration -= 1
- self.color.alpha = 128 - (16 - @_whiten_duration) * 10
- end
- if @_appear_duration > 0
- @_appear_duration -= 1
- self.opacity = (16 - @_appear_duration) * 16
- end
- if @_escape_duration > 0
- @_escape_duration -= 1
- self.opacity = 256 - (32 - @_escape_duration) * 10
- end
- if @_collapse_duration > 0
- @_collapse_duration -= 1
- self.opacity = 256 - (48 - @_collapse_duration) * 6
- end
- if @_damage_duration > 0
- @_damage_duration -= 1
- case @_damage_duration
- when 38..39
- @_damage_sprite.y -= 4
- when 36..37
- @_damage_sprite.y -= 2
- when 34..35
- @_damage_sprite.y += 2
- when 28..33
- @_damage_sprite.y += 4
- end
- @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
- if @_damage_duration == 0
- dispose_damage
- end
- end
- for anime in @_animation
- if (Graphics.frame_count % 2 == 0)
- anime[2] -= 1
- update_animation(anime)
- end
- end
- if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
- update_loop_animation
- @_loop_animation_index += 1
- @_loop_animation_index %= @_loop_animation.frame_max
- end
- if @_blink
- @_blink_count = (@_blink_count + 1) % 32
- if @_blink_count < 16
- alpha = (16 - @_blink_count) * 6
- else
- alpha = (@_blink_count - 16) * 6
- end
- self.color.set(255, 255, 255, alpha)
- end
- @@_animations.clear
- end
-
- def update_animation(anime)
- if anime[2] > 0
- frame_index = anime[0].frame_max - anime[2]
- cell_data = anime[0].frames[frame_index].cell_data
- position = anime[0].position
- animation_set_sprites(anime[3], cell_data, position)
- for timing in anime[0].timings
- if timing.frame == frame_index
- animation_process_timing(timing, anime[1])
- end
- end
- else
- @@_reference_count[anime[3][0].bitmap] -= 1
- if @@_reference_count[anime[3][0].bitmap] == 0
- anime[3][0].bitmap.dispose
- end
- for sprite in anime[3]
- sprite.dispose
- end
- @_animation.delete(anime)
- end
- end
- def animation_set_sprites(sprites, cell_data, position)
- for i in 0..15
- sprite = sprites[i]
- pattern = cell_data[i, 0]
- if sprite == nil or pattern == nil or pattern == -1
- sprite.visible = false if sprite != nil
- next
- end
- sprite.visible = true
- sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
- if position == 3
- if self.viewport != nil
- sprite.x = self.viewport.rect.width / 2
- if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
- sprite.y = self.viewport.rect.height - 320
- else
- sprite.y = self.viewport.rect.height - 160
- end
- else
- sprite.x = 320
- sprite.y = 240
- end
- else
- sprite.x = self.x + self.viewport.rect.x -
- self.ox + self.src_rect.width / 2
- if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
- sprite.y = self.y - self.oy * self.zoom_y / 2 +
- self.viewport.rect.y
- if position == 0
- sprite.y -= self.src_rect.height * self.zoom_y / 4
- elsif position == 2
- sprite.y += self.src_rect.height * self.zoom_y / 4
- end
- else
- sprite.y = self.y + self.viewport.rect.y -
- self.oy + self.src_rect.height / 2
- sprite.y -= self.src_rect.height / 4 if position == 0
- sprite.y += self.src_rect.height / 4 if position == 2
- end
- end
- sprite.x += cell_data[i, 1]
- sprite.y += cell_data[i, 2]
- sprite.z = 2000
- sprite.ox = 96
- sprite.oy = 96
- sprite.zoom_x = cell_data[i, 3] / 100.0
- sprite.zoom_y = cell_data[i, 3] / 100.0
- if position != 3
- sprite.zoom_x *= self.zoom_x
- sprite.zoom_y *= self.zoom_y
- end
- sprite.angle = cell_data[i, 4]
- sprite.mirror = (cell_data[i, 5] == 1)
- sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
- sprite.blend_type = cell_data[i, 7]
- end
- end
- end
- end
复制代码
好记的名字于2011-8-27 14:48补充以下内容:
已解决。。貌似是这个- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
- #==============================================================================
- # ■ Sprite_Base
- #------------------------------------------------------------------------------
- # 处理动画显示追加活动块的类变量。
- #==============================================================================
- class Sprite_Base < Sprite
- #--------------------------------------------------------------------------
- # ● 类变量
- # @@animations 用来记录动画正在播放,防止同一时间多次在同位置播放全屏动画
- # @@_reference_count 用来记录哪些素材正在被使用
- #--------------------------------------------------------------------------
- @@animations = []
- @@_reference_count = {}
- #--------------------------------------------------------------------------
- # ● done 初始化对像
- # viewport : 视口
- #--------------------------------------------------------------------------
- def initialize(viewport = nil)
- super(viewport)
- @use_sprite = true # 活动块使用标记
- @animation_duration = 0 # 动画剩余时间
- # 基本结构:animation, mirror, length, sprites, ox, oy ,[bitmap1, bitmap2]
- @animation_collection = []
- end
- #--------------------------------------------------------------------------
- # ● done 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- return if @animation_collection == nil
- for ani in @animation_collection
- dispose_animation(ani)
- end
- end
- #--------------------------------------------------------------------------
- # ● done 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- if @animation_collection != nil
- @animation_duration -= 1
- for ani in @animation_collection
- ani[2] -= 1
- if ani[2] % 4 == 0
- update_animation(ani)
- end
- end
- end
- @@animations.clear
- end
- #--------------------------------------------------------------------------
- # ● done 动画显示中判定
- #--------------------------------------------------------------------------
- def animation?
- return @animation_collection != nil
- end
- #--------------------------------------------------------------------------
- # ● done 开始动画
- #--------------------------------------------------------------------------
- def start_animation(animation, mirror = false)
- @animation = animation
- return if @animation == nil
- @animation_mirror = mirror
- animation_length = @animation.frame_max * 4 + 1
- @animation_duration += animation_length
- animbitmap = load_animation_bitmap
- @animation_sprites = []
- if @animation.position != 3 or not @@animations.include?(animation)
- if @use_sprite
- for i in 0..15
- sprite = ::Sprite.new(viewport)
- sprite.visible = false
- @animation_sprites.push(sprite)
- end
- unless @@animations.include?(animation)
- @@animations.push(animation)
- end
- end
- end
- if @animation.position == 3
- if viewport == nil
- @animation_ox = 544 / 2
- @animation_oy = 416 / 2
- else
- @animation_ox = viewport.rect.width / 2
- @animation_oy = viewport.rect.height / 2
- end
- else
- @animation_ox = x - ox + width / 2
- @animation_oy = y - oy + height / 2
- if @animation.position == 0
- @animation_oy -= height / 2
- elsif @animation.position == 2
- @animation_oy += height / 2
- end
- end
- @animation_collection.push([@animation, @animation_mirror, animation_length,
- @animation_sprites, @animation_ox, @animation_oy,
- animbitmap])
- end
- #--------------------------------------------------------------------------
- # ● done 读取动画的类变量
- #--------------------------------------------------------------------------
- def load_animation_bitmap
- animation1_name = @animation.animation1_name
- animation1_hue = @animation.animation1_hue
- animation2_name = @animation.animation2_name
- animation2_hue = @animation.animation2_hue
- @animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
- @animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
- if @@_reference_count.include?(@animation_bitmap1)
- @@_reference_count[@animation_bitmap1] += 1
- else
- @@_reference_count[@animation_bitmap1] = 1
- end
- if @@_reference_count.include?(@animation_bitmap2)
- @@_reference_count[@animation_bitmap2] += 1
- else
- @@_reference_count[@animation_bitmap2] = 1
- end
- Graphics.frame_reset
- return [@animation_bitmap1, @animation_bitmap2]
- end
- #--------------------------------------------------------------------------
- # ● done 释放动画
- #--------------------------------------------------------------------------
- def dispose_animation(ani)
- if ani[6][0] != nil
- @@_reference_count[ani[6][0]] -= 1
- if @@_reference_count[ani[6][0]] == 0
- ani[6][0].dispose
- end
- end
- if ani[6][1] != nil
- @@_reference_count[ani[6][1]] -= 1
- if @@_reference_count[ani[6][1]] == 0
- ani[6][1].dispose
- end
- end
- if ani[3] != nil
- for sprite in ani[3]
- sprite.dispose
- end
- @animation_sprites = nil
- @animation = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● done 刷新动画
- #--------------------------------------------------------------------------
- def update_animation(ani)
- if ani[2] > 0
- frame_index = ani[0].frame_max - (ani[2] + 3) / 4
- animation_set_sprites(ani[0].frames[frame_index], ani)
- for timing in ani[0].timings
- if timing.frame == frame_index
- animation_process_timing(timing)
- end
- end
- else
- dispose_animation(ani)
- end
- end
- #--------------------------------------------------------------------------
- # ● done 设置动画活动块
- # frame : 帧数据 (RPG::Animation::Frame)
- #--------------------------------------------------------------------------
- def animation_set_sprites(frame, ani)
- cell_data = frame.cell_data
- for i in 0..15
- sprite = ani[3][i]
- next if sprite == nil
- pattern = cell_data[i, 0]
- if pattern == nil or pattern == -1
- sprite.visible = false
- next
- end
- if pattern < 100
- sprite.bitmap = ani[6][0]
- else
- sprite.bitmap = ani[6][1]
- end
- sprite.visible = true
- sprite.src_rect.set(pattern % 5 * 192,
- pattern % 100 / 5 * 192, 192, 192)
- if @animation_mirror
- sprite.x = ani[4] - cell_data[i, 1]
- sprite.y = ani[5] - cell_data[i, 2]
- sprite.angle = (360 - cell_data[i, 4])
- sprite.mirror = (cell_data[i, 5] == 0)
- else
- sprite.x = ani[4] + cell_data[i, 1]
- sprite.y = ani[5] + cell_data[i, 2]
- sprite.angle = cell_data[i, 4]
- sprite.mirror = (cell_data[i, 5] == 1)
- end
- sprite.z = self.z + 300
- sprite.ox = 96
- sprite.oy = 96
- sprite.zoom_x = cell_data[i, 3] / 100.0
- sprite.zoom_y = cell_data[i, 3] / 100.0
- sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
- sprite.blend_type = cell_data[i, 7]
- end
- end
- #--------------------------------------------------------------------------
- # ● done SE 与闪烁的时机处理
- # timing : Timing数据 (RPG::Animation::Timing)
- #--------------------------------------------------------------------------
- def animation_process_timing(timing)
- timing.se.play
- case timing.flash_scope
- when 1
- self.flash(timing.flash_color, timing.flash_duration * 4)
- when 2
- if viewport != nil
- viewport.flash(timing.flash_color, timing.flash_duration * 4)
- end
- when 3
- self.flash(nil, timing.flash_duration * 4)
- end
- end
- end
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
复制代码
好记的名字于2011-8-27 14:49补充以下内容:
已解决。。。。。。。
好记的名字于2011-8-27 14:52补充以下内容:
已解决 |
|