查看: 3043|回复: 4

[原创发布] 让RM中的动画倒着放

[复制链接]
梦石
3
星屑
50
在线时间
177 小时
注册时间
2008-3-21
回帖
712
发表于 2010-8-24 20:20:48 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 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)

评分

参与人数 1星屑 +500 收起 理由
后知后觉 + 500 鼓励II

查看全部评分

我的个人空间:
http://434986751.qzone.qq.com

剑仙·影羽

梦石
0
星屑
172
在线时间
224 小时
注册时间
2010-3-20
回帖
1535
发表于 2010-8-24 20:32:17 | 显示全部楼层
LZ牛
脚本技术比我好……

点评

第二行可以作为第一行的必要非充分条件。  发表于 2010-8-24 20:46

——至今为止,谁也没能分析出他们为什么会因为说了这些话而死。
回复

使用道具 举报

梦石
3
星屑
50
在线时间
177 小时
注册时间
2008-3-21
回帖
712
 楼主| 发表于 2010-8-24 20:40:12 | 显示全部楼层
紧急修正:

范例工程少了一个end,现已补上。
我的个人空间:
http://434986751.qzone.qq.com
回复

使用道具 举报

剑仙·影羽

梦石
0
星屑
172
在线时间
224 小时
注册时间
2010-3-20
回帖
1535
发表于 2010-8-24 20:43:07 | 显示全部楼层
幸好我早就发现了…………

——至今为止,谁也没能分析出他们为什么会因为说了这些话而死。
回复

使用道具 举报

梦石
0
星屑
301
在线时间
573 小时
注册时间
2005-10-27
回帖
1124
发表于 2010-8-31 02:20:48 | 显示全部楼层
挺有创意的啊~
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部