Sha256: deb2221d4b7d4af440584aa9902c86005fd989b814f01eaf9597696fa7805845
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
module Ray # Animations lists are collections of animations, updating them and # removing all the animations that are done running. As this the only thing # you'll need to do most of the time, you can just push an animation at the # end of it and let {Scene} do the rest of the work. # # @example # animations << color_variation(:from => [255, 0, 0], :to => [0, 255, 0], # :duration => 3).start(sprite) # class AnimationList include Enumerable def initialize @animations = [] end # @return [true, false] True if the animation list is empty def empty? @animations.empty? end # @param [Ray::Animation] elem An animation to add to the animation list. def <<(elem) @animations << elem self end # Updates all the animations, and removes those that are finished. def update @animations.reject! do |anim| anim.update !anim.running? && !anim.paused? end self end # @yield Iterates over all of the animations. # @yieldparam [Ray::Animation] anim An animation. def each(&block) @animations.each(&block) self end def inspect "#{self.class}#{@animations.inspect}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ray-0.1.1 | lib/ray/animation_list.rb |
ray-0.1.0 | lib/ray/animation_list.rb |