Sha256: 5cf51257ecefe40e87c9c6e9de16d4815360633dcbe7f5ff5d6cb491b8b8ee3a
Contents?: true
Size: 1.54 KB
Versions: 4
Compression:
Stored size: 1.54 KB
Contents
module Ray class Animation # Stores an array of animations that will be executed sequentially. # # Registered as animation_sequence. class Sequence < Animation register_for :animation_sequence # @param [Array<Animation>] animations Animation to execute def setup(*animations) @animations = animations @current_anim = nil self.duration = @animations.inject(0) { |sum, a| sum + a.duration } end def setup_target @animations.each { |anim| anim.event_runner = event_runner } @animations.each_cons(2) do |prev, succ| on :animation_end, prev do @current_anim = succ succ.start target end end @current_anim = @animations.first @current_anim.start target end def update_target @current_anim.update end def pause_animation @current_anim.pause end def resume_animation @current_anim.resume end # Adds several animations to the sequence. def push(*animations) @animations.concat(animations) self.duration += animations.inject(0) { |sum, a| sum + a.duration } self end alias :<< :push # @return [Ray::Animation::Sequence] Animation sequence, calling reversed # animations in reversed order. def -@ anims = @animations.reverse.map { |anim| -anim } animation_sequence(*anims) end # @return [Array<Ray::Animation>] attr_reader :animations end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ray-0.2.1 | lib/ray/animation/sequence.rb |
ray-0.2.0 | lib/ray/animation/sequence.rb |
ray-0.1.1 | lib/ray/animation/sequence.rb |
ray-0.1.0 | lib/ray/animation/sequence.rb |