Options
All
  • Public
  • Public/Protected
  • All
Menu

A single tile in a tileset.

Hierarchy

Index

Constructors

constructor

Properties

Readonly animated

animated: boolean

Indicates whether this tile is animated.

see

frames for the animation frames.

Readonly asset

asset: null | 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

frames

frames: frame[]

This tile’s animation as an array of frames.

Readonly height

height: number

Height of the tile in pixels.

Readonly id

id: number

ID of this tile within its tileset.

image

image: Image

Returns the image of this tile, or the image of its tileset if it doesn't have an individual one.

Note that a tile represents a sub-rectangle of its image (or its tileset's image), even if is part of an image collection tileset. The imageRect property provides access to this sub-rectangle. If you need a copy of the tile's image that is already cropped to this sub-rectangle, you can use the following snippet:

let image = tile.image.copy(tile.imageRect);

You can assign an Image to this property to change the tile's image. See setImage for more information.

since

1.11

imageFileName

imageFileName: string

File name of the tile image (when the tile is part of an image collection tileset).

imageRect

imageRect: rect

The source rectangle (in pixels) for this tile.

This can be either a sub-rectangle of the tile image when the tile is part of an image collection tileset or the sub-rectangle of the tileset image.

This property can currently only be modified when the tile is part of an image collection. For tileset image based tiles, it is read-only.

since

1.9

objectGroup

objectGroup: ObjectGroup

The ObjectGroup associated with the tile in case collision shapes were defined. Returns null if no collision shapes were defined for this tile.

probability

probability: number

Probability that the tile gets chosen relative to other tiles.

Readonly readOnly

readOnly: boolean

Whether the object is read-only.

Readonly size

size: size

Size of the tile in pixels.

Readonly tileset

tileset: Tileset

The tileset of the tile.

type

type: string

Type of the tile.

deprecated

Use TiledObject.className instead.

Readonly width

width: number

Width of the tile in pixels.

Static Readonly FlippedAntiDiagonally

FlippedAntiDiagonally: 4

Static Readonly FlippedHorizontally

FlippedHorizontally: 1

Static Readonly FlippedVertically

FlippedVertically: 2

Static Readonly RotatedHexagonal120

RotatedHexagonal120: 8

Methods

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.

removeProperty

  • removeProperty(name: string): void

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

    deprecated

    Use setProperty with a value created by tiled.color instead.

  • 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

    deprecated

    Use setProperty with a value created by tiled.color instead.

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

setImage

  • setImage(image: Image, source?: string): void
  • Sets the image of this tile, optionally also setting its file name. The existing image file name is cleared.

    You should prefer to just set the imageFileName when possible. This function is mostly useful when the image data is loaded from a custom format.

    If an image is set directly on a tile, without specifying its file name, when saving the tileset the image data will be embedded for formats that support this (currently only TMX/TSX).

    note

    Before Tiled 1.11, this function did not change the image file name. For compatibility, set imageFileName before calling this function, if necessary.

    warning

    This function has no undo!

setProperties

setProperty

  • Sets the value of the custom property with the given name.

    Supported types are bool, number, string, color, FilePath, ObjectRef, MapObject and PropertyValue.

    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.

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

    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.

    since

    1.11

Generated using TypeDoc