Class: Smalruby3::Costume
- Inherits:
-
Object
- Object
- Smalruby3::Costume
- Defined in:
- lib/smalruby3/costume.rb
Instance Attribute Summary collapse
-
#asset_id ⇒ Object
readonly
Returns the value of attribute asset_id.
-
#bitmap_resolution ⇒ Object
readonly
Returns the value of attribute bitmap_resolution.
-
#data_format ⇒ Object
readonly
Returns the value of attribute data_format.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rotation_center_x ⇒ Object
readonly
Returns the value of attribute rotation_center_x.
-
#rotation_center_y ⇒ Object
readonly
Returns the value of attribute rotation_center_y.
Instance Method Summary collapse
- #height ⇒ Object
- #height_scale ⇒ Object
- #image ⇒ Object
-
#initialize(asset) ⇒ Costume
constructor
A new instance of Costume.
- #width ⇒ Object
- #width_scale ⇒ Object
Constructor Details
#initialize(asset) ⇒ Costume
Returns a new instance of Costume.
10 11 12 13 14 15 16 17 |
# File 'lib/smalruby3/costume.rb', line 10 def initialize(asset) @asset_id = asset[:asset_id] @name = asset[:name] @bitmap_resolution = asset[:bitmap_resolution] || 1 @data_format = asset[:data_format] @rotation_center_x = asset[:rotation_center_x] @rotation_center_y = asset[:rotation_center_y] end |
Instance Attribute Details
#asset_id ⇒ Object (readonly)
Returns the value of attribute asset_id.
3 4 5 |
# File 'lib/smalruby3/costume.rb', line 3 def asset_id @asset_id end |
#bitmap_resolution ⇒ Object (readonly)
Returns the value of attribute bitmap_resolution.
5 6 7 |
# File 'lib/smalruby3/costume.rb', line 5 def bitmap_resolution @bitmap_resolution end |
#data_format ⇒ Object (readonly)
Returns the value of attribute data_format.
6 7 8 |
# File 'lib/smalruby3/costume.rb', line 6 def data_format @data_format end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/smalruby3/costume.rb', line 4 def name @name end |
#rotation_center_x ⇒ Object (readonly)
Returns the value of attribute rotation_center_x.
7 8 9 |
# File 'lib/smalruby3/costume.rb', line 7 def rotation_center_x @rotation_center_x end |
#rotation_center_y ⇒ Object (readonly)
Returns the value of attribute rotation_center_y.
8 9 10 |
# File 'lib/smalruby3/costume.rb', line 8 def rotation_center_y @rotation_center_y end |
Instance Method Details
#height ⇒ Object
27 28 29 |
# File 'lib/smalruby3/costume.rb', line 27 def height @height ||= image.height * height_scale end |
#height_scale ⇒ Object
35 36 37 |
# File 'lib/smalruby3/costume.rb', line 35 def height_scale @height_scale ||= World.instance.s2dx.scale / bitmap_resolution end |
#image ⇒ Object
19 20 21 |
# File 'lib/smalruby3/costume.rb', line 19 def image @image ||= DXRuby::Image.load(asset_path) end |
#width ⇒ Object
23 24 25 |
# File 'lib/smalruby3/costume.rb', line 23 def width @width ||= image.width * width_scale end |
#width_scale ⇒ Object
31 32 33 |
# File 'lib/smalruby3/costume.rb', line 31 def width_scale @width_scale ||= World.instance.s2dx.scale / bitmap_resolution end |