Constructs a new map.
The asset this object is part of, or null
.
The type of this asset.
Background color of the map.
The current layer.
The signal emitted when currentLayer changes.
File name of the asset.
The signal emitted when fileName changes.
Its first parameter is the new file name, the second parameter is the old file name.
Height of the map in tiles (only relevant for non-infinite maps).
Length of the side of a hexagonal tile (used by tile layers on hexagonal maps).
Whether this map is infinite.
Whether the asset is a TileMap.
Whether the asset is a Tileset.
Number of top-level layers the map has.
The format in which the layer data is stored, taken into account by TMX, JSON and Lua map formats.
The top-level layers of this map. To access nested layers, use GroupLayer.layers.
Whether the asset was modified after it was saved or loaded.
The signal emitted when modified changes.
General map orientation
The parallax origin used for reference when applying the respective parallax factor.
Whether the object is read-only.
Tile rendering order (only implemented for orthogonal maps)
The selected area of tiles.
Selected layers.
The order of the layers is always bottom to top, with selected group layers coming after any of their selected children.
The signal emitted when selectedLayers changes.
Selected objects.
The order of the objects is their display order (when ObjectGroup.IndexOrder is used).
The signal emitted when selectedObjects changes.
Size of the map in tiles (only relevant for non-infinite maps).
For staggered and hexagonal maps, determines which axis (X or Y) is staggered.
For staggered and hexagonal maps, determines whether the even or odd indexes along the staggered axis are shifted.
Tile height (used by tile layers).
Tile width (used by tile layers).
The list of tilesets referenced by this map. To determine which tilesets are actually used, call usedTilesets.
Width of the map in tiles (only relevant for non-infinite maps).
Adds the layer to the map, above all existing layers. The layer can’t already be part of a map.
Adds the given tileset to the list of tilesets referenced by this map. Returns true if the tileset was added, or false if the tileset was already referenced by this map.
Applies Automapping using the given rules file or rule map file.
When no rules file nor rule map file is given, Automapping is applied using the default rules file.
Applies Automapping in the given region using the given rules file or rule map file.
When no rules file nor rule map file is given, Automapping is applied using the default rules file.
Inserts the layer at the given index. The layer can’t already be part of a map.
Returns a reference to the top-level layer at the given index. When the layer gets removed from the map, the reference changes to a standalone copy of the layer.
Creates a single undo command that wraps all changes applied to this asset by the given callback. Recommended to avoid spamming the undo stack with small steps that the user does not care about.
Example function that changes visibility of multiple layers in one step:
tileMap.macro((visible ? "Show" : "Hide") + " Selected Layers", function() {
tileMap.selectedLayers.forEach(function(layer) {
layer.visible = visible
})
})
The returned value is whatever the callback function returned.
Merges the tile layers in the given map with this one. If only a single tile layer exists in the given map, it will be merged with the currentLayer.
Normally, merging tile layers will ignore empty areas in the source map. However, when edits to tile layers in the source map have previously been made through TileLayerEdit.setTile, these edits are applied regardless of whether the tiles are empty or not. This enables erasing of tiles, for example when merging the Tool.preview.
This operation can currently only be applied to maps open in the editor.
If canJoin
is true, the operation joins with the previous one on the
undo stack when possible. Useful for reducing the amount of undo commands.
Converts the given position from pixel to screen coordinates.
Converts the given position from pixel to screen coordinates.
Converts the given position from pixel to tile coordinates.
Converts the given position from pixel to tile coordinates.
Returns all custom properties set on this object.
Modifications to the properties will not affect the original object. Does not include inherited values (see resolvedProperties).
Returns the value of the custom property with the given name, or
undefined
if no such property is set on the object. Does not
include inherited values (see resolvedProperty).
file
properties are returned as FilePath.
object
properties are returned as MapObject when possible,
or ObjectRef when the object could not be found.
Redoes the last change that was undone.
Removes the given layer from the map. The reference to the layer becomes a standalone copy.
Removes the top-level layer at the given index. When a reference to the layer still exists, that reference becomes a standalone copy of the layer.
Removes the given objects from this map. The object references turn into a standalone copy of the object.
Removes the custom property with the given name.
Removes the given tileset from the list of tilesets referenced by this map. Returns true on success, or false when the given tileset was not referenced by this map or when the tileset was still in use by a tile layer or tile object.
Replaces all occurrences of oldTileset with newTileset. Returns true on success, or false when either the old tileset was not referenced by the map, or when the new tileset was already referenced by the map.
Resizes the map to the given size, optionally applying an offset (in tiles).
This operation can currently only be applied to maps loaded from a file.
See also setSize.
Returns all custom properties set on this object. Modifications to the properties will not affect the original object. Includes values inherited from object types, templates and tiles where applicable.
Returns the value of the custom property with the given name, or
undefined
if no such property is set. Includes values inherited
from object types, templates and tiles where applicable.
Save this asset to disk. Returns true if the asset was saved successfully.
Errors are reported by the UI. When an editor is open for this asset, this editor is activated when an error is reported.
Only supported with the editor running, not when running scripts on the CLI. Also, the asset should already have an associated file.
To save assets to a specific file or in a different format, use tiled.mapFormat or tiled.tilesetFormat. This is currently not supported for worlds.
Converts the given position from screen to pixel coordinates.
Converts the given position from screen to pixel coordinates.
Converts the given position from screen to tile coordinates.
Converts the given position from screen to tile coordinates.
Sets the value of the custom property with the given name to the given color value.
The color is specified as a string "#RGB", "#RRGGBB" or "#AARRGGBB".
Sets the value of the custom property with the given name to the given color value.
The color is specified by its red, green, blue and alpha components. Each component takes a value from 0 to 255. When not provided, the alpha defaults to 255.
Sets the value of the custom property with the given name to the given float value.
This function is provided as alternative to setProperty, since
that function will set whole numbers as int
properties.
Replaces all currently set custom properties with a new set of properties.
Sets the value of the custom property with the given name.
Supported types are bool
, number
, string
, color,
FilePath, ObjectRef, MapObject and
PropertyValue.
Sets the value of an object's property identified by the given path to the given value.
The path is a list of property names, where each name identifies a member of the previous member's value. The last name in the list identifies the property to set.
Supported types are bool
, number
, string
, color,
FilePath, ObjectRef, MapObject and
PropertyValue.
Sets the size of the map in tiles. This does not affect the contents of the map.
See also resize.
Sets the tile size of the map in pixels. This affects the rendering of all tile layers.
Converts the given position from tile to pixel coordinates.
Converts the given position from tile to pixel coordinates.
Converts the given position from tile to screen coordinates.
Converts the given position from tile to screen coordinates.
Renders the map to an image. When no size is given, creates an image the size of the map.
Undoes the last applied change.
Returns the list of tilesets actually used by this map. This is generally a subset of the tilesets referenced by the map (the tilesets property).
Generated using TypeDoc
A tile-map asset.
Usually this asset defines a specific level or area in a game.
Contrary to the name, this is not necessary a tile-map. The contents are defined by the layers that are added to it, which could also include only image and object layers. Yet, this class has many properties that affect how the tile layers are rendered.