Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

Readonly asset

asset: Asset

The asset this object is part of, or null.

backgroundColor

backgroundColor: color

Background color of the map.

currentLayer

currentLayer: Layer

The current layer.

Readonly fileName

fileName: string

File name of the asset.

height

height: number

Height of the map in tiles (only relevant for non-infinite maps).

hexSideLength

hexSideLength: number

Length of the side of a hexagonal tile (used by tile layers on hexagonal maps).

infinite

infinite: boolean

Whether this map is infinite.

Readonly isTileMap

isTileMap: boolean

Whether the asset is a TileMap.

Readonly isTileset

isTileset: boolean

Whether the asset is a Tileset.

Readonly layerCount

layerCount: number

Number of top-level layers the map has.

layerDataFormat

layerDataFormat: typeof XML | typeof Base64 | typeof Base64Gzip | typeof Base64Zlib | typeof Base64Zstandard | typeof CSV

The format in which the layer data is stored, taken into account by TMX, JSON and Lua map formats.

Readonly modified

modified: boolean

Whether the asset was modified after it was saved or loaded.

orientation

orientation: typeof Unknown | typeof Orthogonal | typeof Isometric | typeof Staggered | typeof Hexagonal

General map orientation

Readonly readOnly

readOnly: boolean

Whether the object is read-only.

renderOrder

renderOrder: typeof RightDown | typeof RightUp | typeof LeftDown | typeof LeftUp

Tile rendering order (only implemented for orthogonal maps)

selectedArea

selectedArea: SelectedArea

The selected area of tiles.

selectedLayers

selectedLayers: Layer[]

Selected layers.

selectedObjects

selectedObjects: MapObject[]

Selected objects.

Readonly size

size: size

Size of the map in tiles (only relevant for non-infinite maps).

staggerAxis

staggerAxis: typeof StaggerX | typeof StaggerY

For staggered and hexagonal maps, determines which axis (X or Y) is staggered.

staggerIndex

staggerIndex: typeof StaggerOdd | typeof StaggerEven

For staggered and hexagonal maps, determines whether the even or odd indexes along the staggered axis are shifted.

tileHeight

tileHeight: number

Tile height (used by tile layers).

tileWidth

tileWidth: number

Tile width (used by tile layers).

tilesets

tilesets: Tileset[]

The list of tilesets referenced by this map. To determine which tilesets are actually used, call usedTilesets().

width

width: number

Width of the map in tiles (only relevant for non-infinite maps).

Static Readonly Base64

Base64: typeof Base64

Static Readonly Base64Gzip

Base64Gzip: typeof Base64Gzip

Static Readonly Base64Zlib

Base64Zlib: typeof Base64Zlib

Static Readonly Base64Zstandard

Base64Zstandard: typeof Base64Zstandard

Static Readonly CSV

CSV: typeof CSV

Static Readonly Hexagonal

Hexagonal: typeof Hexagonal

Static Readonly Isometric

Isometric: typeof Isometric

Static Readonly LeftDown

LeftDown: typeof LeftDown

Static Readonly LeftUp

LeftUp: typeof LeftUp

Static Readonly Orthogonal

Orthogonal: typeof Orthogonal

Static Readonly RightDown

RightDown: typeof RightDown

Static Readonly RightUp

RightUp: typeof RightUp

Static Readonly StaggerEven

StaggerEven: typeof StaggerEven

Static Readonly StaggerOdd

StaggerOdd: typeof StaggerOdd

Static Readonly StaggerX

StaggerX: typeof StaggerX

Static Readonly StaggerY

StaggerY: typeof StaggerY

Static Readonly Staggered

Staggered: typeof Staggered

Static Readonly Unknown

Unknown: typeof Unknown

Static Readonly XML

XML: typeof XML

Methods

addLayer

  • addLayer(layer: Layer): void
  • Adds the layer to the map, above all existing layers. The layer can’t already be part of a map.

addTileset

  • addTileset(tileset: Tileset): boolean
  • 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.

autoMap

  • autoMap(rulesFule?: string): void
  • autoMap(region: rect | region, rulesFile?: string): void
  • Applies Automapping using the given rules file, or using the default rules file is none is given.

    This operation can only be applied to maps loaded from a file.

  • Applies Automapping in the given region using the given rules file, or using the default rules file is none is given.

    This operation can only be applied to maps loaded from a file.

insertLayerAt

  • insertLayerAt(index: number, layer: Layer): void
  • Inserts the layer at the given index. The layer can’t already be part of a map.

layerAt

  • layerAt(index: number): Layer
  • 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.

macro

  • macro<T>(text: string, callback: () => T): T
  • 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.

merge

  • merge(map: TileMap, canJoin?: boolean): void
  • 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.

    This operation can currently only be applied to maps loaded from a file.

    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.

pixelToScreen

  • pixelToScreen(x: number, y: number): point
  • pixelToScreen(position: point): point
  • Converts the given position from pixel to screen coordinates.

  • Converts the given position from pixel to screen coordinates.

pixelToTile

  • pixelToTile(x: number, y: number): point
  • pixelToTile(position: point): point
  • Converts the given position from pixel to tile coordinates.

  • Converts the given position from pixel to tile coordinates.

properties

  • 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).

property

  • 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.

redo

  • redo(): void
  • Redoes the last change that was undone.

    note

    The undo system is only enabled for assets loaded in the editor!

removeLayer

  • removeLayer(layer: Layer): void
  • Removes the given layer from the map. The reference to the layer becomes a standalone copy.

removeLayerAt

  • removeLayerAt(index: number): void
  • 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.

removeProperty

  • removeProperty(name: string): void

removeTileset

  • removeTileset(tileset: Tileset): boolean
  • 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.

replaceTileset

  • 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.

resize

  • resize(size: size, offset?: point, removeObjects?: boolean): void
  • 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.

resolvedProperties

  • 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.

resolvedProperty

  • 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.

screenToPixel

  • screenToPixel(x: number, y: number): point
  • screenToPixel(position: point): point
  • Converts the given position from screen to pixel coordinates.

  • Converts the given position from screen to pixel coordinates.

screenToTile

  • screenToTile(x: number, y: number): point
  • screenToTile(position: point): point
  • Converts the given position from screen to tile coordinates.

  • Converts the given position from screen to tile coordinates.

setProperties

  • Replaces all currently set custom properties with a new set of properties.

setProperty

  • Sets the value of the custom property with the given name. Supported types are bool, number, string, FilePath, ObjectRef and MapObject.

    When setting a number, the property type will be set to either int or float, depending on whether it is a whole number.

    note

    Support for setting color properties is currently missing.

setSize

  • setSize(width: number, height: number): void
  • Sets the size of the map in tiles. This does not affect the contents of the map.

    See also resize.

setTileSize

  • setTileSize(width: number, height: number): void
  • Sets the tile size of the map in pixels. This affects the rendering of all tile layers.

tileToPixel

  • tileToPixel(x: number, y: number): point
  • tileToPixel(position: point): point
  • Converts the given position from tile to pixel coordinates.

  • Converts the given position from tile to pixel coordinates.

tileToScreen

  • tileToScreen(x: number, y: number): point
  • tileToScreen(position: point): point
  • Converts the given position from tile to screen coordinates.

  • Converts the given position from tile to screen coordinates.

undo

  • undo(): void
  • Undoes the last applied change.

    note

    The undo system is only enabled for assets loaded in the editor!

usedTilesets

  • Returns the list of tilesets actually used by this map. This is generally a subset of the tilesets referenced by the map (the TileMap.tilesets property).

Generated using TypeDoc