Class: Bestguigui::Tiled::Map
- Inherits:
-
Object
- Object
- Bestguigui::Tiled::Map
- Defined in:
- lib/bestguigui/tiled.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#layers ⇒ Object
readonly
Returns the value of attribute layers.
-
#tile_height ⇒ Object
readonly
Returns the value of attribute tile_height.
-
#tile_width ⇒ Object
readonly
Returns the value of attribute tile_width.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(path) ⇒ Map
constructor
A new instance of Map.
-
#object_layer(name = nil) ⇒ Object
Première couche d'objets (ou celle nommée
name), ou nil s'il n'y en a pas. -
#tile_layer(name = nil) ⇒ Object
Première couche de tuiles (ou celle nommée
name), ou nil s'il n'y en a pas.
Constructor Details
#initialize(path) ⇒ Map
Returns a new instance of Map.
23 24 25 26 27 28 29 30 |
# File 'lib/bestguigui/tiled.rb', line 23 def initialize(path) data = JSON.parse(File.read(path)) @width = data["width"] @height = data["height"] @tile_width = data["tilewidth"] @tile_height = data["tileheight"] @layers = data["layers"].map { |layer_data| build_layer(layer_data) } end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
21 22 23 |
# File 'lib/bestguigui/tiled.rb', line 21 def height @height end |
#layers ⇒ Object (readonly)
Returns the value of attribute layers.
21 22 23 |
# File 'lib/bestguigui/tiled.rb', line 21 def layers @layers end |
#tile_height ⇒ Object (readonly)
Returns the value of attribute tile_height.
21 22 23 |
# File 'lib/bestguigui/tiled.rb', line 21 def tile_height @tile_height end |
#tile_width ⇒ Object (readonly)
Returns the value of attribute tile_width.
21 22 23 |
# File 'lib/bestguigui/tiled.rb', line 21 def tile_width @tile_width end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
21 22 23 |
# File 'lib/bestguigui/tiled.rb', line 21 def width @width end |
Instance Method Details
#object_layer(name = nil) ⇒ Object
Première couche d'objets (ou celle nommée name), ou nil s'il n'y
en a pas.
40 41 42 |
# File 'lib/bestguigui/tiled.rb', line 40 def object_layer(name = nil) find_layer(ObjectLayer, name) end |