Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TileLayer

A tile layer.

Note that while tile layers have a size, the size is generally ignored on infinite maps. Even for fixed size maps, nothing in the scripting API stops you from changing the layer outside of its boundaries and changing the size of the layer has no effect on its contents. If you want to change the size while affecting the contents, use the resize function.

Hierarchy

Index

Constructors

constructor

Properties

Readonly asset

asset: Asset

The asset this object is part of, or null.

className

className: string

Class name of the object.

Replaced the "type" of MapObject and Tile in Tiled 1.9.

since

1.9

height

height: number

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

Readonly id

id: number

Unique (map-wide) ID of the layer

since

1.5

Readonly isGroupLayer

isGroupLayer: boolean

Whether this layer is a GroupLayer.

Readonly isImageLayer

isImageLayer: boolean

Whether this layer is an ImageLayer.

Readonly isObjectLayer

isObjectLayer: boolean

Whether this layer is an ObjectGroup.

Readonly isTileLayer

isTileLayer: boolean

Whether this layer is a TileLayer.

locked

locked: boolean

Whether the layer is locked (affects whether child layers are locked for group layers).

Readonly map

map: null | TileMap

Map that this layer is part of, or null in case of a standalone layer.

name

name: string

Name of the layer.

offset

offset: point

Offset in pixels that is applied when this layer is rendered.

opacity

opacity: any

Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

parallaxFactor

parallaxFactor: point

The parallax factor of this layer.

Readonly parentLayer

parentLayer: null | GroupLayer

The group layer this layer is part of, or null in case the layer is not grouped.

Readonly readOnly

readOnly: boolean

Whether the object is read-only.

selected

selected: boolean

Whether the layer is selected.

size

size: size

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

tintColor

tintColor: color

Tint color of the layer. Will be used to tint any images rendered by this layer or by any child layers. Affects tile layers, image layers and tile objects.

Since Tiled 1.8.5, this property is #ffffff when no tint color has been set on this layer (before it was #000000 in that case).

since

1.8

visible

visible: boolean

Whether the layer is visible (affects child layer visibility for group layers).

width

width: number

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

Methods

cellAt

  • cellAt(x: number, y: number): cell
  • Returns the value of the cell at the given position. Can be used to query the flags and the tile ID, but does not currently allow getting a tile reference (see tileAt).

edit

  • Returns an object that enables making modifications to the tile layer.

flagsAt

  • flagsAt(x: number, y: number): number
  • Returns the flags used for the tile at the given position.

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.

region

  • Returns the region of the layer that is covered with tiles.

removeProperty

  • removeProperty(name: string): void

resize

  • Resizes the layer, erasing the part of the contents that falls outside of the layer’s new size. The offset parameter can be used to shift the contents by a certain distance in tiles before applying the resize.

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.

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.

tileAt

  • tileAt(x: number, y: number): null | Tile
  • Returns the tile used at the given position, or null for empty spaces.

Generated using TypeDoc