Class: Tmx::Map

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/tmx/map.rb

Instance Method Summary collapse

Instance Method Details

#image_layersObject



28
29
30
# File 'lib/tmx/map.rb', line 28

def image_layers
  @object_groups ||= Array(contents['image_layers']).map {|layer| ImageLayer.new layer.merge(contents: layer) }
end

#layersObject



11
12
13
# File 'lib/tmx/map.rb', line 11

def layers
  @layers ||= Array(contents['layers']).map {|layer| Layer.new layer.merge(contents: layer) }
end

#object_groupsObject



19
20
21
# File 'lib/tmx/map.rb', line 19

def object_groups
  @object_groups ||= Array(contents['object_groups']).map {|group| ObjectGroup.new group.merge(contents: group) }
end

#objectsObjects

Returns an array-like object of all the objects within the map.

Returns:

  • (Objects)

    an array-like object of all the objects within the map



24
25
26
# File 'lib/tmx/map.rb', line 24

def objects
  Objects.new object_groups.map {|og| og.objects }.flatten
end

#tilesetsObject



15
16
17
# File 'lib/tmx/map.rb', line 15

def tilesets
  @tilesets ||= Array(contents['tilesets']).map {|set| TileSet.new set.merge(contents: set) }
end