Class: Dedalus::Elements::Sprite

Inherits:
Image show all
Defined in:
lib/dedalus/elements/sprite.rb

Instance Attribute Summary collapse

Attributes inherited from Image

#invert_x, #invert_y, #overlay_color, #padding, #path, #z_order

Attributes inherited from Atom

#padding

Attributes inherited from Dedalus::Element

#background_color, #color, #height_percent, #margin, #offset, #padding, #position, #shown, #width_percent, #z_order

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Image

#dimensions, #offset, #overlay_gosu_color, #render

Methods inherited from Dedalus::Element

#big_font, #code_font, #draw_bounding_box, #font, #huge_font, #initialize, #record?, #tiny_font, #view, #window

Constructor Details

This class inherits a constructor from Dedalus::Element

Instance Attribute Details

#asset_heightObject

Returns the value of attribute asset_height.



4
5
6
# File 'lib/dedalus/elements/sprite.rb', line 4

def asset_height
  @asset_height
end

#asset_widthObject

Returns the value of attribute asset_width.



4
5
6
# File 'lib/dedalus/elements/sprite.rb', line 4

def asset_width
  @asset_width
end

#frameObject

Returns the value of attribute frame.



4
5
6
# File 'lib/dedalus/elements/sprite.rb', line 4

def frame
  @frame
end

Class Method Details

.descriptionObject



33
34
35
# File 'lib/dedalus/elements/sprite.rb', line 33

def self.description
  "an animated image"
end

.example_dataObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/dedalus/elements/sprite.rb', line 22

def self.example_data
  {
    path: "media/images/tiles.png",
    frame: 3,
    asset_width: 64,
    asset_height: 64,
    invert_x: true,
    scale: 2.5
  }
end

Instance Method Details

#assetObject



6
7
8
# File 'lib/dedalus/elements/sprite.rb', line 6

def asset
  @asset ||= Dedalus::ImageRepository.lookup_tiles(path, asset_width, asset_height)[frame]
end

#heightObject



18
19
20
# File 'lib/dedalus/elements/sprite.rb', line 18

def height
  2*padding + (asset_height * scale)
end

#scaleObject



10
11
12
# File 'lib/dedalus/elements/sprite.rb', line 10

def scale
  @scale ||= 1.0
end

#widthObject



14
15
16
# File 'lib/dedalus/elements/sprite.rb', line 14

def width
  2*padding + (asset_width * scale)
end