Class: Osb::Sprite
Overview
A still image.
Instance Method Summary collapse
-
#initialize(layer: Layer::Background, origin: Origin::Center, file_path:, initial_position: nil) ⇒ Sprite
constructor
A new instance of Sprite.
Methods included from Commandable
#additive_color_blending, #color, #fade, #flip, #move, #move_x, #move_y, #rotate, #scale, #trigger
Constructor Details
#initialize(layer: Layer::Background, origin: Origin::Center, file_path:, initial_position: nil) ⇒ Sprite
Returns a new instance of Sprite.
14 15 16 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 |
# File 'lib/osb/sprite.rb', line 14 def initialize( layer: Layer::Background, origin: Origin::Center, file_path:, initial_position: nil ) Internal.assert_type!(layer, String, "layer") Internal.assert_value!(layer, Layer::ALL, "layer") Internal.assert_type!(origin, String, "origin") Internal.assert_value!(origin, 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, Osb::Vector2, "initial_position" ) end @layer = layer first_command = "Sprite,#{layer},#{origin},\"#{file_path}\"" if initial_position first_command += ",#{initial_position.x},#{initial_position.y}" end # @type [Array<String>] @commands = [first_command] end |