Options
All
  • Public
  • Public/Protected
  • All
Menu

A container for tiles that can be used by a map.

Can contain either tiles cut from a single image, by setting image or calling loadFromImage, or individual tiles using addTile and then setting the image on each tile using Tile.imageFileName or Tile.setImage.

Hierarchy

Index

Constructors

constructor

  • new Tileset(name?: string): Tileset

Properties

Readonly asset

asset: null | Asset

The asset this object is part of, or null.

backgroundColor

backgroundColor: color

Background color for this tileset in the Tilesets view.

className

className: string

Class name of the object.

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

since

1.9

Readonly collection

collection: boolean

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

deprecated

Use isCollection instead.

columnCount

columnCount: number

The number of tile columns in this tileset.

Can be changed in case of image-collection tilesets, in which case it determines the number of columns used in the tileset view when dynamic wrapping is disabled.

since

1.9

Readonly fileName

fileName: string

File name of the asset.

Readonly fileNameChanged

fileNameChanged: Signal<string>

The signal emitted when fileName changes.

Its first parameter is the new file name, the second parameter is the old file name.

fillMode

fillMode: typeof Stretch | typeof PreserveAspectFit

The fill mode to use when rendering tiles from this tileset. Only relevant when the tiles are not rendered at their native size.

since

1.9

image

image: string

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

note

You'll want to set up the tile size, tile spacing, margin and transparent color as appropriate before setting this property, to avoid repeatedly setting up the tiles in response to changing parameters.

note

Map files are supported tileset image source as well.

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

since

1.10

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.

Readonly modifiedChanged

modifiedChanged: Signal<null>

The signal emitted when modified changes.

name

name: string

Name of the tileset.

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

See TilesetsView.selectedTiles for getting the selected tiles in the Tilesets view.

Readonly tileCount

tileCount: number

The number of tiles in this tileset.

tileHeight

tileHeight: number

Tile Height for tiles in this tileset in pixels.

note

Changing this property will cause an image-based tileset to update all its tiles. When setting up a tileset, you'll want to set this property before setting the image property.

tileOffset

tileOffset: point

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

tileRenderSize

tileRenderSize: typeof TileSize | typeof GridSize

The size to use when rendering tiles from this tileset on a tile layer.

since

1.9

tileSize

tileSize: size

Tile size for tiles in this tileset in pixels.

note

Changing this property will cause an image-based tileset to update all its tiles. When setting up a tileset, you'll want to set this property before setting the image property.

Readonly tileSpacing

tileSpacing: number

Spacing between tiles in this tileset in pixels.

tileWidth

tileWidth: number

Tile width for tiles in this tileset in pixels.

note

Changing this property will cause an image-based tileset to update all its tiles. When setting up a tileset, you'll want to set this property before setting the image property.

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.

transparentColor

transparentColor: color

Color used as transparent color when rendering tiles from this tileset.

This property is currently not supported for image collection tilesets.

note

Changing this property will cause an image-based tileset to update all its tiles. When setting up a tileset, you'll want to set this property before setting the image property.

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 GridSize

GridSize: typeof GridSize

Static Readonly Isometric

Isometric: typeof Isometric

Static Readonly Left

Left: typeof Left

Static Readonly Orthogonal

Orthogonal: typeof Orthogonal

Static Readonly PreserveAspectFit

PreserveAspectFit: typeof PreserveAspectFit

Static Readonly Right

Right: typeof Right

Static Readonly Stretch

Stretch: typeof Stretch

Static Readonly TileSize

TileSize: typeof TileSize

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

  • Add a new Wang set to this tileset with the given name and type.

findTile

  • findTile(id: number): null | Tile
  • Returns a reference to the tile with the given ID, or null 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.

    since

    1.9.2

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.

    note

    Usually you'll just want to assign the image file name to the image property!

    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.

setColorProperty

  • setColorProperty(name: string, value: color): void
  • setColorProperty(name: string, red: number, green: number, blue: number, alpha?: number): void
  • 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".

    since

    1.10

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

    since

    1.10

setFloatProperty

  • setFloatProperty(name: string, value: number): void
  • 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.

    since

    1.10

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.

    note

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

    note

    This function does not support setting color properties. Use setColorProperty instead.

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