Class: Kawaii::TmxTileMap
- Inherits:
-
Object
- Object
- Kawaii::TmxTileMap
- Defined in:
- lib/kawaii/tmx_tile_map.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#layers ⇒ Object
Returns the value of attribute layers.
-
#orientation ⇒ Object
Returns the value of attribute orientation.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#texture ⇒ Object
Returns the value of attribute texture.
-
#tile_height ⇒ Object
Returns the value of attribute tile_height.
-
#tile_width ⇒ Object
Returns the value of attribute tile_width.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize ⇒ TmxTileMap
constructor
A new instance of TmxTileMap.
- #load(path, content_manager) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ TmxTileMap
Returns a new instance of TmxTileMap.
8 9 10 11 12 |
# File 'lib/kawaii/tmx_tile_map.rb', line 8 def initialize @layers = [] @properties = {} @tilesets = [] end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/kawaii/tmx_tile_map.rb', line 6 def height @height end |
#layers ⇒ Object
Returns the value of attribute layers.
6 7 8 |
# File 'lib/kawaii/tmx_tile_map.rb', line 6 def layers @layers end |
#orientation ⇒ Object
Returns the value of attribute orientation.
6 7 8 |
# File 'lib/kawaii/tmx_tile_map.rb', line 6 def orientation @orientation end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/kawaii/tmx_tile_map.rb', line 6 def properties @properties end |
#texture ⇒ Object
Returns the value of attribute texture.
6 7 8 |
# File 'lib/kawaii/tmx_tile_map.rb', line 6 def texture @texture end |
#tile_height ⇒ Object
Returns the value of attribute tile_height.
6 7 8 |
# File 'lib/kawaii/tmx_tile_map.rb', line 6 def tile_height @tile_height end |
#tile_width ⇒ Object
Returns the value of attribute tile_width.
6 7 8 |
# File 'lib/kawaii/tmx_tile_map.rb', line 6 def tile_width @tile_width end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/kawaii/tmx_tile_map.rb', line 6 def width @width end |
Instance Method Details
#draw ⇒ Object
14 15 16 17 18 |
# File 'lib/kawaii/tmx_tile_map.rb', line 14 def draw @layers.each do |layer| layer.draw end end |
#load(path, content_manager) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/kawaii/tmx_tile_map.rb', line 20 def load path, content_manager if path.end_with? ".json" load_json path @layers.each do |layer| layer.textures = content_manager.load_tiled_images(@tilesets.first.gsub(/\.\.\//, ""), 32) end else raise UnsupportedFormatError, "only json is supported" end end |
#to_s ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kawaii/tmx_tile_map.rb', line 31 def to_s puts "Width: #{@width}" puts "Height: #{@height}" puts "Orientation: #{@orientation}" puts "Tile width: #{@tile_width}" puts "Tile height: #{@tile_height}" puts "" puts "Properties" properties.each do |k, v| puts "Key: #{k}, Value: #{v}" end puts "" puts "Layers: " @layers.each do |l| puts l.to_s end end |