赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 8 |
经验 | 132 |
最后登录 | 2014-9-6 |
在线时间 | 1270 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 777
- 在线时间
- 1270 小时
- 注册时间
- 2011-2-14
- 帖子
- 5589
|
把这个脚本贴上去,然后你就知道了,现在设定是1号动画链接2号动画- #=============================================================================
- # 设定
- #=============================================================================
- $an = { #动画编号 => [2号动画启动时机(帧),2号动画的id]
- 1 => [10,2] #1号动画在第10帧启动2号动画
- }
- module RPG
- class Sprite < ::Sprite
- def animation(animation, hit)
- dispose_animation
- @_animation = animation
- return if @_animation == nil
- @_animation_hit = hit
- @_animation_duration = @_animation.frame_max
- animation_name = @_animation.animation_name
- animation_hue = @_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
- @_animation_sprites = []
- if @_animation.position != 3 or not @@_animations.include?(animation)
- for i in 0..15
- sprite = ::Sprite.new(self.viewport)
- sprite.bitmap = bitmap
- sprite.visible = false
- @_animation_sprites.push(sprite)
- end
- unless @@_animations.include?(animation)
- @@_animations.push(animation)
- end
- end
- update_animation
- end
- def dispose_animation
- if @_animation_sprites != nil
- sprite = @_animation_sprites[0]
- if sprite != nil
- @@_reference_count[sprite.bitmap] -= 1
- if @@_reference_count[sprite.bitmap] == 0
- sprite.bitmap.dispose
- end
- end
- for sprite in @_animation_sprites
- sprite.dispose
- end
- @_animation_sprites = nil
- @_animation = nil
- 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
- if @_animation != nil and (Graphics.frame_count % 2 == 0)
- @_animation_duration -= 1
- update_animation
- 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
- frame_index = @_animation.frame_max - @_animation_duration - 1
- cell_data = @_animation.frames[frame_index].cell_data
- position = @_animation.position
- animation_set_sprites(@_animation_sprites, cell_data, position)
- for timing in @_animation.timings
- if timing.frame == frame_index
- animation_process_timing(timing, @_animation_hit)
- end
- end
- if @_animation_duration > 0
- if $an.include?(@_animation.id)
- if $an[@_animation.id][0] == frame_index
- animation22222222($data_animations[$an[@_animation.id][1]], @_animation_hit)
- end
- end
- else
- dispose_animation
- end
- end
- def update_loop_animation
- frame_index = @_loop_animation_index
- cell_data = @_loop_animation.frames[frame_index].cell_data
- position = @_loop_animation.position
- animation_set_sprites(@_loop_animation_sprites, cell_data, position)
- for timing in @_loop_animation.timings
- if timing.frame == frame_index
- animation_process_timing(timing, true)
- end
- 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
- sprite.y = self.viewport.rect.height - 160
- else
- sprite.x = 320
- sprite.y = 240
- end
- else
- sprite.x = self.x - self.ox + self.src_rect.width / 2
- sprite.y = self.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
- 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
- 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
- def animation_process_timing(timing, hit)
-
- if (timing.condition == 0) or
- (timing.condition == 1 and hit == true) or
- (timing.condition == 2 and hit == false)
- if timing.se.name != ""
- se = timing.se
- Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
- end
- case timing.flash_scope
- when 1
- self.flash(timing.flash_color, timing.flash_duration * 2)
- when 2
- if self.viewport != nil
- self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
- end
- when 3
- self.flash(nil, timing.flash_duration * 2)
- end
- end
- end
- def x=(x)
- sx = x - self.x
- if sx != 0
- if @_animation_sprites != nil
- for i in 0..15
- @_animation_sprites[i].x += sx
- end
- end
- if @_loop_animation_sprites != nil
- for i in 0..15
- @_loop_animation_sprites[i].x += sx
- end
- end
- end
- super
- end
- def y=(y)
- sy = y - self.y
- if sy != 0
- if @_animation_sprites != nil
- for i in 0..15
- @_animation_sprites[i].y += sy
- end
- end
- if @_loop_animation_sprites != nil
- for i in 0..15
- @_loop_animation_sprites[i].y += sy
- end
- end
- end
- super
- end
- end
- end
- module RPG
- class Sprite < ::Sprite
- @@_animation22222222s = []
- @@_animations = []
- @@_reference_count = {}
- def initialize(viewport = nil)
- super(viewport)
- @_whiten_duration = 0
- @_appear_duration = 0
- @_escape_duration = 0
- @_collapse_duration = 0
- @_damage_duration = 0
- @_animation22222222_duration = 0
- @_animation_duration = 0
- @_blink = false
- end
- def dispose
- dispose_damage
- dispose_animation22222222
- dispose_animation
- dispose_loop_animation
- super
- end
- def animation22222222(animation22222222, hit)
- dispose_animation22222222
- @_animation22222222 = animation22222222
- return if @_animation22222222 == nil
- @_animation22222222_hit = hit
- @_animation22222222_duration = @_animation22222222.frame_max
- animation22222222_name = @_animation22222222.animation_name
- animation22222222_hue = @_animation22222222.animation_hue
- bitmap = RPG::Cache.animation(animation22222222_name, animation22222222_hue)
- if @@_reference_count.include?(bitmap)
- @@_reference_count[bitmap] += 1
- else
- @@_reference_count[bitmap] = 1
- end
- @_animation22222222_sprites = []
- if @_animation22222222.position != 3 or not @@_animation22222222s.include?(animation22222222)
- for i in 0..15
- sprite = ::Sprite.new(self.viewport)
- sprite.bitmap = bitmap
- sprite.visible = false
- @_animation22222222_sprites.push(sprite)
- end
- unless @@_animation22222222s.include?(animation22222222)
- @@_animation22222222s.push(animation22222222)
- end
- end
- update_animation22222222
- end
- def dispose_animation22222222
- if @_animation22222222_sprites != nil
- sprite = @_animation22222222_sprites[0]
- if sprite != nil
- @@_reference_count[sprite.bitmap] -= 1
- if @@_reference_count[sprite.bitmap] == 0
- sprite.bitmap.dispose
- end
- end
- for sprite in @_animation22222222_sprites
- sprite.dispose
- end
- @_animation22222222_sprites = nil
- @_animation22222222 = nil
- 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
- if @_animation != nil and (Graphics.frame_count % 2 == 0)
- @_animation_duration -= 1
- update_animation
- end
- if @_animation22222222 != nil and (Graphics.frame_count % 2 == 0)
- @_animation22222222_duration -= 1
- update_animation22222222
- 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
- @@_animation22222222s.clear
- end
- def update_animation22222222
- if @_animation22222222_duration > 0
- frame_index = @_animation22222222.frame_max - @_animation22222222_duration
- cell_data = @_animation22222222.frames[frame_index].cell_data
- position = @_animation22222222.position
- animation22222222_set_sprites(@_animation22222222_sprites, cell_data, position)
- for timing in @_animation22222222.timings
- if timing.frame == frame_index
- animation22222222_process_timing(timing, @_animation22222222_hit)
- end
- end
- else
- dispose_animation22222222
- end
- end
- def animation22222222_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
- sprite.y = self.viewport.rect.height - 160
- else
- sprite.x = 320
- sprite.y = 240
- end
- else
- sprite.x = self.x - self.ox + self.src_rect.width / 2
- sprite.y = self.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
- 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
- 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
- def animation22222222_process_timing(timing, hit)
- if (timing.condition == 0) or
- (timing.condition == 1 and hit == true) or
- (timing.condition == 2 and hit == false)
- if timing.se.name != ""
- se = timing.se
- Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
- end
- case timing.flash_scope
- when 1
- self.flash(timing.flash_color, timing.flash_duration * 2)
- when 2
- if self.viewport != nil
- self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
- end
- when 3
- self.flash(nil, timing.flash_duration * 2)
- end
- end
- end
- def x=(x)
- sx = x - self.x
- if sx != 0
- if @_animation22222222_sprites != nil
- for i in 0..15
- @_animation22222222_sprites[i].x += sx
- end
- end
- if @_loop_animation_sprites != nil
- for i in 0..15
- @_loop_animation_sprites[i].x += sx
- end
- end
- end
- super
- end
- def effect?
- @_whiten_duration > 0 or
- @_appear_duration > 0 or
- @_escape_duration > 0 or
- @_collapse_duration > 0 or
- @_damage_duration > 0 or
- @_animation_duration > 0 or
- @_animation22222222_duration > 0
- end
- def y=(y)
- sy = y - self.y
- if sy != 0
- if @_animation22222222_sprites != nil
- for i in 0..15
- @_animation22222222_sprites[i].y += sy
- end
- end
- if @_loop_animation_sprites != nil
- for i in 0..15
- @_loop_animation_sprites[i].y += sy
- end
- end
- end
- super
- end
- end
- end
复制代码 |
|