Class: Smalruby3::Costume

Inherits:
Object
  • Object
show all
Defined in:
lib/smalruby3/costume.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject (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_resolutionObject (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_formatObject (readonly)

Returns the value of attribute data_format.



6
7
8
# File 'lib/smalruby3/costume.rb', line 6

def data_format
  @data_format
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/smalruby3/costume.rb', line 4

def name
  @name
end

#rotation_center_xObject (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_yObject (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

#heightObject



27
28
29
# File 'lib/smalruby3/costume.rb', line 27

def height
  @height ||= image.height * height_scale
end

#height_scaleObject



35
36
37
# File 'lib/smalruby3/costume.rb', line 35

def height_scale
  @height_scale ||= World.instance.s2dx.scale / bitmap_resolution
end

#imageObject



19
20
21
# File 'lib/smalruby3/costume.rb', line 19

def image
  @image ||= DXRuby::Image.load(asset_path)
end

#widthObject



23
24
25
# File 'lib/smalruby3/costume.rb', line 23

def width
  @width ||= image.width * width_scale
end

#width_scaleObject



31
32
33
# File 'lib/smalruby3/costume.rb', line 31

def width_scale
  @width_scale ||= World.instance.s2dx.scale / bitmap_resolution
end