Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObjectGroup

The "ObjectGroup" is a type of layer that can contain objects. It will henceforth be referred to as a layer.

Hierarchy

Index

Constructors

constructor

  • Constructs a new object layer, which can be added to a TileMap.

Properties

Readonly asset

asset: Asset

The asset this object is part of, or null.

color

color: color

Color of shape and point objects on this layer (when not set by object type).

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

map

map: TileMap

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

name

name: string

Name of the layer.

Readonly objectCount

objectCount: number

Number of objects on this layer.

Readonly objects

objects: MapObject[]

Array of all objects on this 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).

Readonly readOnly

readOnly: boolean

Whether the object is read-only.

selected

selected: boolean

Whether the layer is selected.

visible

visible: boolean

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

Methods

addObject

  • Adds the given object to the layer. The object can’t already be part of a layer.

insertObjectAt

  • insertObjectAt(index: number, object: MapObject): void
  • Inserts the object at the given index. The object can’t already be part of a layer.

objectAt

  • Returns a reference to the object at the given index. When the object is removed, the reference turns into a standalone copy of the object.

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.

removeObject

  • Removes the given object from this layer. The object reference turns into a standalone copy of the object.

removeObjectAt

  • removeObjectAt(index: number): void
  • Removes the object at the given index.

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.

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.

Generated using TypeDoc