-
Notifications
You must be signed in to change notification settings - Fork 30
A map is returned after using the Loader to load a tmx file. Maps are made up of Tiles, TileLayers, TileSets, Objects, and ObjectLayers.
##Public
###Data
Map.name (default: "
)
The name of the map.
Map.width (default: 0
)
The width of the map in tiles.
Map.height (default: 0
)
The height of the map in tiles.
Map.tileWidth (default: 0
)
The uniform width of tiles in pixels
Map.tileHeight (default: 0
)
The uniform height of tiles in pixels.
Map.orientation (default: "orthogonal"
)
The orientation of the map. Can either be "orthogonal" or "isometric".
Map.properties (default: {}
)
The properties of the map set in Tiled.
Map.useSpriteBatch (default: false
)
If true then all tile layers will be rendered with sprite batches. Can be set with the map property [atl`useSpriteBatch](ATL Properties).
Map.visible (default: true
)
If false then the map will not be drawn.
Map.drawObjects (default: true
)
If this is true then ObjectLayers will be drawn. The default value can be set from
Loader.drawObjects or the map property [atl`drawObjects](ATL Properties).
Map.viewX (default: 0
)
The x coordinant for the top-left of the viewable area. Can be set with the map property [atl`viewX](ATL Properties).
Map.viewY (default: 0
)
The x coordinant for the top-left of the viewable area. Can be set with the map property [atl`viewY](ATL Properties).
Map.viewW (default: love.graphics.getWidth()
)
The width of the viewable area. Can be set with the map property [atl`viewW](ATL Properties).
Map.viewH (default: love.graphics.getHeight()
)
The height of the viewable area. Can be set with the map property [atl`viewH](ATL Properties).
Map.viewScaling (default: 1
)
The scaling of the view. 1 = 100% size. Can be set with the map property [atl`viewScaling](ATL Properties).
Map.viewPadding (default: true
)
The padding around the view area. Use this if for some reason you can see parts of the map not being drawn. Can be set with the map property [atl`viewPadding](ATL Properties).
Map.offsetX (default: 0
)
The horizontal offset for the map. Can be set with the map property [atl`offsetX](ATL Properties).
Map.offsetY (default: 0
)
The vertical offset for the map. Can be set with the map property [atl`offsetY](ATL Properties).
Map.layers (default: {}
)
The TileLayers, ObjectLayers, and CustomLayers in the map indexed by name.
Map.tilesets (default: {}
)
The TileSets in the map indexed by filename.
Map.tiles (default: {}
)
The Tiles in the map indexed by id.
Map.layerOrder (default: {}
)
A list of the layers in the map in the order they are drawn.
Map.class (default: "Map"
)
The class name
###Functions
Map:new (name, width, height, tileWidth, tileHeight, orientation, properties
)
Creates a new empty map and returns it. Most likely you'll want to Load a map instead.
Map:updateTiles ()
This will cut the Tiles out of TileSets and add them to Map. This needs to be called when a TileSet changes or is added. Unless you are manually adding TileSets then you shouldn't have to worry about this. Done automatically when a map is loaded.
Map:newTileSet (img, name, tilew, tileh, width, height, firstgid, space, marg, tprop
)
Creates a new TileSet and adds it to the map.
Map:newTileLayer (name, opacity, properties, position
)
Creates a new TileLayer and adds it to the map.
Map:newObjectLayer (name, color, opacity, properties, position
)
Creates a new ObjectLayer and adds it to the map.
Map:newCustomLayer (name, position, layer
)
Creates a new CustomLayer and adds it to the map.
Map:forceRedraw ()
Normally sprite batches are only redrawn when the viewable tiles change. You can call this to force them to redraw.
Map:callback (name, ...
)
Forwards a callback to all layers inside layerOrder. If a layer has a function with the same name as the callback then it will be triggered. The most common callback is draw but other callbacks can be used to give functionality to custom layers.
Map:draw ()
Draws the map. This is just a shortcut for Map:callback("draw").
Map:layerPosition (layer
)
Returns the position of the layer
inside the Map.drawList. Returns nil if it can't be found.
Map:swapLayers (layer1, layer2
)
Swaps the position of two layers inside Map.layerPosition
Map:removeLayer (layer
)
Removes a layer completely from the map.
Map:fromIso (x, y
)
Turns an isometric location into a world location. The unit length for isometric tiles is always the map's tileHeight. This is both for width and height.
Map:toIso (x, y
)
Turns a world location into an isometric location.
Map:setDrawRange (x, y, w, h
)
Sets the draw range.
Map:autoDrawRange (tx, ty, scale, pad
)
Automatically sets the draw range given the scale
and translation (tx, ty
) of the view.
Map:getDrawRange ()
Returns the draw range.
Map:``call (layerName)
Calling the map like a function with a layer name as a parameter will return that layer.
##Private
###Data
**Map.widestTile** (
default: 0`)
The width of the widest tile on the map.
**Map.highestTile** (
default: 0`)
The height of the tallest tile on the map
**Map.forceRedraw** (
default: false`)
If true then then special redraw will be force for the next Map.updateTileRange call.
**Map.previousUseSpriteBatch** (
default: false`)
The previous Map.useSpriteBatch value. If this changed then sprite batches will be redrawn.
**Map.tileClipboard** (
default: false`)
The value that stored for tile copying and pasting.
**Map.directory** (
default: nil) The directory to start from to load resources when loading the map. Mainly used for saving and written to atl
directory.
###Functions
**Map.updateTileRange** () This updates the Map.
tileRange, Map.previousTileRange, and Map.
specialRedraw. It is called right before the map draws.