Module: OR2D::Animations::CompositeAnimations
- Included in:
- Composites::Sprite, Composites::Text
- Defined in:
- lib/or2d/animations/composite_animations.rb
Overview
A module that provides functions for animating the layers of a Composite object.
Instance Method Summary collapse
-
#fade(speed: nil, target: :all) ⇒ Object
Fade the a single layer of a Composite object, or all layers if no target is specified.
-
#fade_in(speed: nil, target: :all) ⇒ Object
Fade in a single layer of a Composite object, or all layers if no target is specified.
-
#fade_out(speed: nil, target: :all) ⇒ Object
Fade out a single layer of a Composite object, or all layers if no target is specified.
-
#grow(factor: 1.0, delay: 100, target: :all) ⇒ Object
Grow a single layer of a Composite object, or all layers if no target is specified.
-
#grow_entity(factor: nil, delay: nil, target: :all) ⇒ Object
Grow the entity of a single layer of a Composite object, or all layers if no target is specified.
-
#grow_text_composite(factor: nil, delay: nil, target: :all) ⇒ Object
Grow the text of a single layer of a Composite object, or all layers if no target is specified.
-
#rotation(speed: 0.1, angle: 360, clockwise: true, target: :all) ⇒ Object
Rotate a single layer of a Composite object, or all layers if no target is specified.
-
#shake(target: :all, duration: 100, magnitude: 10) ⇒ Object
Shake a single layer of a Composite object, or all layers if no target is specified.
-
#shrink(factor: 1.0, delay: 100, target: :all) ⇒ Object
Shrink a single layer of a Composite object, or all layers if no target is specified.
-
#shrink_entity(factor: nil, delay: nil, target: nil) ⇒ Object
Shrinks the entity of a single layer of a Composite object, or all layers if no target is specified.
-
#shrink_text(factor: nil, delay: nil, target: :all) ⇒ Object
Shrink the text of a single layer of a Composite object, or all layers if no target is specified.
Instance Method Details
#fade(speed: nil, target: :all) ⇒ Object
Fade the a single layer of a Composite object, or all layers if no target is specified.
9 10 11 12 13 14 15 16 17 |
# File 'lib/or2d/animations/composite_animations.rb', line 9 def fade(speed: nil, target: :all) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].fade(speed: speed) end else OR2D.game.entities[@layers.keys[target]].fade(speed: speed) end end |
#fade_in(speed: nil, target: :all) ⇒ Object
Fade in a single layer of a Composite object, or all layers if no target is specified.
22 23 24 25 26 27 28 29 30 |
# File 'lib/or2d/animations/composite_animations.rb', line 22 def fade_in(speed: nil, target: :all) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].fade_in(speed: speed) end else OR2D.game.entities[@layers.keys[target]].fade_in(speed: speed) end end |
#fade_out(speed: nil, target: :all) ⇒ Object
Fade out a single layer of a Composite object, or all layers if no target is specified.
35 36 37 38 39 40 41 42 43 |
# File 'lib/or2d/animations/composite_animations.rb', line 35 def fade_out(speed: nil, target: :all) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].fade_out(speed: speed) end else OR2D.game.entities[@layers.keys[target]].fade_out(speed: speed) end end |
#grow(factor: 1.0, delay: 100, target: :all) ⇒ Object
Grow a single layer of a Composite object, or all layers if no target is specified.
64 65 66 67 68 69 70 71 72 |
# File 'lib/or2d/animations/composite_animations.rb', line 64 def grow(factor: 1.0, delay: 100, target: :all) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].grow(factor: factor, delay: delay) end else OR2D.game.entities[@layers.keys[target]].grow(factor: factor, delay: delay) end end |
#grow_entity(factor: nil, delay: nil, target: :all) ⇒ Object
Grow the entity of a single layer of a Composite object, or all layers if no target is specified.
92 93 94 95 96 97 98 99 100 |
# File 'lib/or2d/animations/composite_animations.rb', line 92 def grow_entity(factor: nil, delay: nil, target: :all) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].grow_entity(factor: factor, delay: delay) end else OR2D.game.entities[@layers.keys[target]].grow_entity(factor: factor, delay: delay) end end |
#grow_text_composite(factor: nil, delay: nil, target: :all) ⇒ Object
Grow the text of a single layer of a Composite object, or all layers if no target is specified.
78 79 80 81 82 83 84 85 86 |
# File 'lib/or2d/animations/composite_animations.rb', line 78 def grow_text_composite(factor: nil, delay: nil, target: :all) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].grow_text(factor: factor, delay: delay) end else OR2D.game.entities[@layers.keys[target]].grow_text(factor: factor, delay: delay) end end |
#rotation(speed: 0.1, angle: 360, clockwise: true, target: :all) ⇒ Object
Rotate a single layer of a Composite object, or all layers if no target is specified.
50 51 52 53 54 55 56 57 58 |
# File 'lib/or2d/animations/composite_animations.rb', line 50 def rotation(speed: 0.1, angle: 360, clockwise: true, target: :all) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].rotation(speed: speed, angle: angle, clockwise: clockwise) end else OR2D.game.entities[@layers.keys[target]].rotation(speed: speed, angle: angle, clockwise: clockwise) end end |
#shake(target: :all, duration: 100, magnitude: 10) ⇒ Object
Shake a single layer of a Composite object, or all layers if no target is specified.
149 150 151 152 153 154 155 156 157 |
# File 'lib/or2d/animations/composite_animations.rb', line 149 def shake(target: :all, duration: 100, magnitude: 10) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].shake(duration: duration, magnitude: magnitude) end else OR2D.game.entities[@layers.keys[target]].shake(duration: duration, magnitude: magnitude) end end |
#shrink(factor: 1.0, delay: 100, target: :all) ⇒ Object
Shrink a single layer of a Composite object, or all layers if no target is specified.
106 107 108 109 110 111 112 113 114 |
# File 'lib/or2d/animations/composite_animations.rb', line 106 def shrink(factor: 1.0, delay: 100, target: :all) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].shrink(factor: factor, delay: delay) end else OR2D.game.entities[@layers.keys[target]].shrink(factor: factor, delay: delay) end end |
#shrink_entity(factor: nil, delay: nil, target: nil) ⇒ Object
Shrinks the entity of a single layer of a Composite object, or all layers if no target is specified.
134 135 136 137 138 139 140 141 142 |
# File 'lib/or2d/animations/composite_animations.rb', line 134 def shrink_entity(factor: nil, delay: nil, target: nil) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].shrink_entity(factor: factor, delay: delay) end else OR2D.game.entities[@layers.keys[target]].shrink_entity(factor: factor, delay: delay) end end |
#shrink_text(factor: nil, delay: nil, target: :all) ⇒ Object
Shrink the text of a single layer of a Composite object, or all layers if no target is specified.
120 121 122 123 124 125 126 127 128 |
# File 'lib/or2d/animations/composite_animations.rb', line 120 def shrink_text(factor: nil, delay: nil, target: :all) if target == :all @layers.each_key do |layer| OR2D.game.entities[layer].shrink_text(factor: factor, delay: delay) end else OR2D.game.entities[@layers.keys[target]].shrink_text(factor: factor, delay: delay) end end |