Project1
标题:
让RM中的动画倒着放
[打印本页]
作者:
slick
时间:
2010-8-24 20:20
标题:
让RM中的动画倒着放
本帖最后由 slick 于 2010-8-24 20:39 编辑
你是否为了出招的启动、收招的倒回而烦恼?
你是否想表现一种“时光倒流”的效果?
你是否想制作出“收回”法术的特效?
那么,现在你不用分别为两种效果单独制作动画了,一个开关就搞定!
外挂脚本如下:
$正反控制开关 = 1
module RPG
class Sprite < ::Sprite
def animation(animation, hit)
dispose_animation
@_animation = animation
return if @_animation == nil
@_animation_hit = hit
@_animation_duration = $game_switches[$正反控制开关] ? 1 : @_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 loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
@_loop_animation_index = $game_switches[$正反控制开关] ? @_loop_animation.frame_max : 1
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(self.viewport)
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
update_loop_animation
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)
if $game_switches[$正反控制开关]
@_animation_duration += 1
else
@_animation_duration -= 1
end
update_animation
end
if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
update_loop_animation
if $game_switches[$正反控制开关]
@_loop_animation_index -= 1
if @_loop_animation_index < 0
@_loop_animation_index = @_loop_animation.frame_max - 1
end
else
@_loop_animation_index += 1
@_loop_animation_index %= @_loop_animation.frame_max
end
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
continueflag = true
if $game_switches[$正反控制开关]
if @_animation_duration > @_animation.frame_max
continueflag = false
end
else
if @_animation_duration <= 0
continueflag = false
end
end
if continueflag
frame_index = @_animation.frame_max - @_animation_duration
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
else
dispose_animation
end
end
end
end
范例工程:
动画倒放.rar
(315.83 KB, 下载次数: 178)
2010-8-24 20:39 上传
点击文件名下载附件
作者:
火ZHI意志
时间:
2010-8-24 20:32
LZ牛
脚本技术比我好……
作者:
slick
时间:
2010-8-24 20:40
紧急修正:
范例工程少了一个end,现已补上。
作者:
火ZHI意志
时间:
2010-8-24 20:43
幸好我早就发现了…………
作者:
姬文翔
时间:
2010-8-31 02:20
挺有创意的啊~
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1