Class: Osb::Animation
- Inherits:
-
Object
- Object
- Osb::Animation
- Includes:
- Commandable
- Defined in:
- lib/osb/animation.rb
Overview
A moving image.
Instance Attribute Summary collapse
- #commands ⇒ Object readonly private
- #layer ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(layer: Osb::Layer::Background, origin: Osb::Origin::Center, file_path:, initial_position: nil, frame_count:, frame_delay:, repeat: false) ⇒ Animation
constructor
A new instance of Animation.
Methods included from Commandable
#additive_color_blending, #color, #fade, #flip, #move, #move_x, #move_y, #rotate, #scale, #trigger
Constructor Details
#initialize(layer: Osb::Layer::Background, origin: Osb::Origin::Center, file_path:, initial_position: nil, frame_count:, frame_delay:, repeat: false) ⇒ Animation
Returns a new instance of Animation.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/osb/animation.rb', line 17 def initialize( layer: Osb::Layer::Background, origin: Osb::Origin::Center, file_path:, initial_position: nil, frame_count:, frame_delay:, repeat: false ) Internal.assert_type!(layer, String, "layer") Internal.assert_value!(layer, Osb::Layer::ALL, "layer") Internal.assert_type!(origin, String, "origin") Internal.assert_value!(origin, Osb::Origin::ALL, "origin") Internal.assert_type!(file_path, String, "file_path") Internal.assert_file_name_ext!(file_path, %w[png jpg jpeg]) if initial_position Internal.assert_type!(initial_position, Vector2, "initial_position") end Internal.assert_type!(frame_count, Integer, "frame_count") Internal.assert_type!(frame_delay, Integer, "frame_delay") Internal.assert_type!(repeat, Internal::Boolean, "repeat") @layer = layer first_command = "Animation,#{layer},#{origin},\"#{file_path}\"" if initial_position first_command += ",#{initial_position.x},#{initial_position.y}" else first_command += ",," end first_command += ",#{frame_count}" first_command += ",#{frame_delay}" looptype = repeat ? "LoopForever" : "LoopOnce" first_command += ",#{type}" if repeat # @type [Array<String>] @commands = [first_command] end |
Instance Attribute Details
#commands ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 |
# File 'lib/osb/animation.rb', line 7 def commands @commands end |
#layer ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 |
# File 'lib/osb/animation.rb', line 7 def layer @layer end |