Module: Tmx

Extended by:
Tmx
Included in:
Tmx
Defined in:
lib/tmx.rb,
lib/tmx/map.rb,
lib/tmx/layer.rb,
lib/tmx/object.rb,
lib/tmx/objects.rb,
lib/tmx/version.rb,
lib/tmx/tile_set.rb,
lib/tmx/image_layer.rb,
lib/tmx/parsers/tmx.rb,
lib/tmx/object_group.rb,
lib/tmx/parsers/json.rb,
lib/tmx/parsers/parsers.rb,
lib/tmx/parsers/unknown.rb

Defined Under Namespace

Modules: Parser, Parsers Classes: ImageLayer, Layer, Map, Object, ObjectGroup, Objects, TileSet

Constant Summary collapse

VERSION =
"0.1.5"

Instance Method Summary collapse

Instance Method Details

#load(filename, options = {}) ⇒ Object

Load the specified TMX file and return a Map that was found.

Parameters:

  • filename (String)

    the name fo the Tiled Map file.

  • options (Hash) (defaults to: {})


18
19
20
21
22
23
# File 'lib/tmx.rb', line 18

def load(filename,options={})
  options = default_options(filename).merge(options)

  # Pass :filename in options for resolving relative "source" paths
  parse contents(filename), options.merge(:filename => filename)
end

#parse(contents, options = {}) ⇒ Object

Parse the the string contents of a TMX file.



29
30
31
32
# File 'lib/tmx.rb', line 29

def parse(contents,options={})
  contents = parser(options).parse contents
  Map.new contents.merge(contents: contents)
end