Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MapObject

An object that can be part of an ObjectGroup.

Hierarchy

Index

Constructors

constructor

  • Constructs a new map object, which can be added to an ObjectGroup.

  • Constructs a new map object of the given shape, which can be added to an ObjectGroup.

Properties

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

font

font: Font

The font of a text object.

height

height: number

Height of the object in pixels.

Readonly id

id: number

Unique (map-wide) ID of the object.

layer

layer: null | ObjectGroup

Layer this object is part of (or null in case of a standalone object).

Readonly map

map: null | TileMap

Map this object is part of (or null in case of a standalone object).

name

name: string

Name of the object.

polygon

polygon: Polygon

Polygon of the object.

pos

pos: point

Position of the object in pixels.

Readonly readOnly

readOnly: boolean

Whether the object is read-only.

rotation

rotation: number

Rotation of the object in degrees clockwise.

selected

selected: boolean

Whether the object is selected.

shape

Shape of the object.

size

size: size

Size of the object in pixels.

text

text: string

The text of a text object.

textAlignment

textAlignment: number

The alignment of a text object. Can be set using a combination of Qt.Alignment flags.

textColor

textColor: color

Color of a text object.

tile

tile: null | Tile

Tile of the object.

tileFlippedHorizontally

tileFlippedHorizontally: boolean

Whether the tile is flipped horizontally.

tileFlippedVertically

tileFlippedVertically: boolean

Whether the tile is flipped vertically.

type

type: string

Type of the object.

deprecated

Use TiledObject.className instead.

visible

visible: boolean

width

width: number

Width of the object in pixels.

wordWrap

wordWrap: boolean

Whether the text of a text object wraps based on the width of the object.

x

x: number

X coordinate of the object in pixels.

y

y: number

Y coordinate of the object in pixels.

Static Readonly Ellipse

Ellipse: typeof Ellipse

Static Readonly Point

Point: typeof Point

Static Readonly Polygon

Polygon: typeof Polygon

Static Readonly Polyline

Polyline: typeof Polyline

Static Readonly Rectangle

Rectangle: typeof Rectangle

Static Readonly Text

Text: typeof Text

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

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 the given \a path to \a value.

    The \a 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