Class: Ray::AnimationList
- Inherits:
-
Object
- Object
- Ray::AnimationList
- Includes:
- Enumerable
- Defined in:
- lib/ray/animation_list.rb
Overview
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.
Instance Method Summary collapse
- #<<(elem) ⇒ Object
- #each {|anim| ... } ⇒ Object
-
#empty? ⇒ true, false
True if the animation list is empty.
-
#initialize ⇒ AnimationList
constructor
A new instance of AnimationList.
- #inspect ⇒ Object
-
#update ⇒ Object
Updates all the animations, and removes those that are finished.
Constructor Details
#initialize ⇒ AnimationList
Returns a new instance of AnimationList.
14 15 16 |
# File 'lib/ray/animation_list.rb', line 14 def initialize @animations = [] end |
Instance Method Details
#<<(elem) ⇒ Object
24 25 26 27 |
# File 'lib/ray/animation_list.rb', line 24 def <<(elem) @animations << elem self end |
#each {|anim| ... } ⇒ Object
41 42 43 44 |
# File 'lib/ray/animation_list.rb', line 41 def each(&block) @animations.each(&block) self end |
#empty? ⇒ true, false
Returns True if the animation list is empty.
19 20 21 |
# File 'lib/ray/animation_list.rb', line 19 def empty? @animations.empty? end |
#inspect ⇒ Object
46 47 48 |
# File 'lib/ray/animation_list.rb', line 46 def inspect "#{self.class}#{@animations.inspect}" end |
#update ⇒ Object
Updates all the animations, and removes those that are finished.
30 31 32 33 34 35 36 37 |
# File 'lib/ray/animation_list.rb', line 30 def update @animations.reject! do |anim| anim.update !anim.running? && !anim.paused? end self end |