Class: Dedalus::Elements::Sprite
- Inherits:
-
Image
- Object
- Dedalus::Element
- Atom
- Image
- Dedalus::Elements::Sprite
- Defined in:
- lib/dedalus/elements/sprite.rb
Instance Attribute Summary collapse
-
#asset_height ⇒ Object
Returns the value of attribute asset_height.
-
#asset_width ⇒ Object
Returns the value of attribute asset_width.
-
#frame ⇒ Object
Returns the value of attribute frame.
Attributes inherited from Image
#invert_x, #invert_y, #overlay_color, #padding, #path, #z_order
Attributes inherited from Atom
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_height ⇒ Object
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_width ⇒ Object
Returns the value of attribute asset_width.
4 5 6 |
# File 'lib/dedalus/elements/sprite.rb', line 4 def asset_width @asset_width end |
#frame ⇒ Object
Returns the value of attribute frame.
4 5 6 |
# File 'lib/dedalus/elements/sprite.rb', line 4 def frame @frame end |
Class Method Details
.description ⇒ Object
33 34 35 |
# File 'lib/dedalus/elements/sprite.rb', line 33 def self.description "an animated image" end |
.example_data ⇒ Object
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
#asset ⇒ Object
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 |
#height ⇒ Object
18 19 20 |
# File 'lib/dedalus/elements/sprite.rb', line 18 def height 2*padding + (asset_height * scale) end |
#scale ⇒ Object
10 11 12 |
# File 'lib/dedalus/elements/sprite.rb', line 10 def scale @scale ||= 1.0 end |
#width ⇒ Object
14 15 16 |
# File 'lib/dedalus/elements/sprite.rb', line 14 def width 2*padding + (asset_width * scale) end |