Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • new Tileset(name?: string): Tileset

Properties

Readonly asset

asset: Asset

The asset this object is part of, or null.

backgroundColor

backgroundColor: color

Background color for this tileset in the Tilesets view.

Readonly fileName

fileName: string

File name of the asset.

image

image: string

The file name of the image used by this tileset. Empty in case of image collection tilesets.

Readonly imageHeight

imageHeight: number

Height of the tileset image in pixels.

Readonly imageSize

imageSize: size

Size of the tileset image in pixels.

Readonly imageWidth

imageWidth: number

Width of the tileset image in pixels.

Readonly isCollection

isCollection: boolean

Whether this tileset is a collection of images (same as checking whether image is an empty string).

Readonly isTileMap

isTileMap: boolean

Whether the asset is a TileMap.

Readonly isTileset

isTileset: boolean

Whether the asset is a Tileset.

Readonly margin

margin: number

Margin around the tileset in pixels (only used at the top and left sides of the tileset image).

Readonly modified

modified: boolean

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

name

name: string

Name of the tileset.

nextTileId

nextTileId: number

The ID of the next tile that would be added to this tileset. All existing tiles have IDs that are lower than this ID.

objectAlignment

objectAlignment: typeof Unspecified | typeof TopLeft | typeof Top | typeof TopRight | typeof Left | typeof Center | typeof Right | typeof BottomLeft | typeof Bottom | typeof BottomRight

The alignment to use for tile objects (when Unspecified, uses Bottom alignment on isometric maps and BottomLeft alignment for all other maps).

orientation

orientation: typeof Orthogonal | typeof Isometric

The orientation of this tileset (used when rendering overlays and in the tile collision editor).

Readonly readOnly

readOnly: boolean

Whether the object is read-only.

selectedTiles

selectedTiles: Tile[]

Selected tiles (in the tileset editor).

tileCount

tileCount: number

The number of tiles in this tileset.

tileHeight

tileHeight: number

Tile Height for tiles in this tileset in pixels.

tileOffset

tileOffset: point

Offset in pixels that is applied when tiles from this tileset are rendered.

tileSize

tileSize: size

Tile size for tiles in this tileset in pixels.

Readonly tileSpacing

tileSpacing: number

Spacing between tiles in this tileset in pixels.

tileWidth

tileWidth: number

Tile width for tiles in this tileset in pixels.

Readonly tiles

tiles: Tile[]

Array of all tiles in this tileset. Note that the index of a tile in this array does not always match with its ID.

Readonly wangSets

wangSets: WangSet[]

Array of all Wang sets in this tileset.

Static Readonly Bottom

Bottom: typeof Bottom

Static Readonly BottomLeft

BottomLeft: typeof BottomLeft

Static Readonly BottomRight

BottomRight: typeof BottomRight

Static Readonly Center

Center: typeof Center

Static Readonly Isometric

Isometric: typeof Isometric

Static Readonly Left

Left: typeof Left

Static Readonly Orthogonal

Orthogonal: typeof Orthogonal

Static Readonly Right

Right: typeof Right

Static Readonly Top

Top: typeof Top

Static Readonly TopLeft

TopLeft: typeof TopLeft

Static Readonly TopRight

TopRight: typeof TopRight

Static Readonly Unspecified

Unspecified: typeof Unspecified

Methods

addTile

  • Adds a new tile to this tileset and returns it. Only works for image collection tilesets.

addWangSet

  • addWangSet(name: string, type: number): WangSet
  • Add a new Wang set to this tileset with the given name and type.

loadFromImage

  • loadFromImage(image: Image, source?: string): void
  • Creates the tiles in this tileset by cutting them out of the given image, using the current tile size, tile spacing and margin parameters. These values should be set before calling this function.

    Optionally sets the source file of the image. This may be useful, but be careful since Tiled will try to reload the tileset from that source when the tileset parameters are changed.

    warning

    This function has no undo!

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.

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!

removeProperty

  • removeProperty(name: string): void

removeTiles

  • removeTiles(tiles: Tile[]): void
  • Removes the given tiles from this tileset. Only works for image collection tilesets.

removeWangSet

  • removeWangSet(wangSet: WangSet): void
  • Removes the given Wang set from this tileset.

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.

setTileSize

  • setTileSize(width: number, height: number): void
  • Sets the tile size for this tileset. If an image has been specified as well, the tileset will be (re)loaded. Can’t be used on image collection tilesets.

tile

  • tile(id: number): Tile
  • Returns a reference to the tile with the given ID. Raises an error if no such tile exists. When the tile gets removed from the tileset, the reference changes to a standalone copy of the tile.

    Note that the tiles in a tileset are only guaranteed to have consecutive IDs for tileset-image based tilesets. For image collection tilesets there will be gaps when tiles have been removed from the tileset.

undo

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

    note

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

Generated using TypeDoc