Class: Ray::AnimationList
- Inherits:
-
Object
- Object
- Ray::AnimationList
- Includes:
- Enumerable, PP
- 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 Attribute Summary collapse
- #animations ⇒ Array<Ray::Animation> (also: #to_a) readonly
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
- #pretty_print(q) ⇒ Object
-
#remove_unused ⇒ Object
Removes animations that are no more in use.
-
#update ⇒ Object
Updates all the animations.
Methods included from PP
Constructor Details
#initialize ⇒ AnimationList
Returns a new instance of AnimationList.
15 16 17 |
# File 'lib/ray/animation_list.rb', line 15 def initialize @animations = [] end |
Instance Attribute Details
#animations ⇒ Array<Ray::Animation> (readonly) Also known as: to_a
53 54 55 |
# File 'lib/ray/animation_list.rb', line 53 def animations @animations end |
Instance Method Details
#<<(elem) ⇒ Object
25 26 27 28 |
# File 'lib/ray/animation_list.rb', line 25 def <<(elem) @animations << elem self end |
#each {|anim| ... } ⇒ Object
47 48 49 50 |
# File 'lib/ray/animation_list.rb', line 47 def each(&block) @animations.each(&block) self end |
#empty? ⇒ true, false
Returns True if the animation list is empty.
20 21 22 |
# File 'lib/ray/animation_list.rb', line 20 def empty? @animations.empty? end |
#inspect ⇒ Object
57 58 59 |
# File 'lib/ray/animation_list.rb', line 57 def inspect "#{self.class}#{@animations.inspect}" end |
#pretty_print(q) ⇒ Object
61 62 63 |
# File 'lib/ray/animation_list.rb', line 61 def pretty_print(q) pretty_print_attributes q, ["animations"] end |
#remove_unused ⇒ Object
Removes animations that are no more in use
37 38 39 40 41 42 43 |
# File 'lib/ray/animation_list.rb', line 37 def remove_unused @animations.reject! do |anim| !anim.running? && !anim.paused? end self end |
#update ⇒ Object
Updates all the animations
31 32 33 34 |
# File 'lib/ray/animation_list.rb', line 31 def update @animations.each(&:update) self end |