Skip to content
Casey Baxter edited this page Oct 30, 2012 · 16 revisions

The Loader module loads a Tiled map (.tmx) with Loader.load() and returns a Map object. You do not need to create an instance of it with new(). It does have some settings you might want to change but otherwise using it is very straightforward.

Example:

local Loader = require "AdvTiledLoader.Loader"
Loader.path = "maps\"
local map = ATL.Loader.load("MyTiledMap.tmx")

Public

Data

Loader.path (default: "")
The path to tmx files from the root of your LOVE game. This is prefixed before the filename when you try and load a map. Handy if you have all your map files in one place but don`t want to type the full path all the time.

Loader.filterMin (default: "nearest")
The min filter to apply to tileset images when they are loaded. Can be set to "nearest" or "linear".

Loader.filterMag (default: "nearest")
The magnify filter to apply to tileset images when they are loaded. Can be set to "nearest" or "linear".

Loader.useSpriteBatch (default: "true")
This value is copied to map.useSpriteBatch when a new Map is loaded. If false then sprite batches will not be used to draw the map.

Loader.drawObjects (default: "true")
This value is copied to map.drawObjects when a new Map is loaded. If false then ObjectLayers will not be drawn.

Loader.saveDirectory (default: "Saved Maps")
The save directory for maps. See Saving for more details.

###Functions Loader.load(filename)
Loads a tiled map from filename and returns it. The filename is prefixed with Loader.path.

Loader.save(map, filename) Saves a loaded tiled map. See Saving for more details.

##Private ###Functions **Loader.newImage**(info`)
Creates and returns a new image from a file or ImageData.

**Loader.checkXML**(t`)
Checks to see if the passed table is in a recognized XML format.

**Loader.checkName**(t, str) This is used to eliminate naming conflicts. If stris found in the tabletthenstr` is renamed until there is no longer a conflict and then returned.

**Loader.expandProperties**(t`)
Processes properties that are set in Tiled and puts them into a table. It automatically converts values into numbers when possible.

**Loader.expandMap**(name, t`)
Processes and returns a Map from an XML table.

**Loader.expandTileSet**(t, map`)
Processes and returns a TileSet from an XML table.

**Loader.expandTileLayer**(t, map`)
Processes and returns a TileLayer from an XML table.

**Loader.expandTileLayerData**(t`)
Processes and returns the tileData of a TileLayer from an XML table.

**Loader.expandObjectLayer**(t`)
Processes and returns an Objectlayer from an XML table.

**Loader.compactMap**(map`)
Compacts a Map into an XML table for saving.

**Loader.compactTileSet**(map`)
Compacts a TileSet into an XML table for saving.

**Loader.compactTileLayer**(map`)
Compacts a TileLayer into an XML table for saving.

**Loader.compactObjectLayer**(map`)
Compacts an ObjectLayer into an XML table for saving.

**Loader.compactObject**(map`)
Compacts an Object into an XML table for saving.

**Loader.compactProperties**(map`)
Compacts a properties into an XML table for saving.


See Also

Map
Home