Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ImageLayer

A layer that renders a single referenced image.

Hierarchy

Index

Constructors

constructor

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

Readonly id

id: number

Unique (map-wide) ID of the layer

since

1.5

image

image: Image

Returns a copy of this layer's image.

When assigning an image to this property, the imageFileName property is cleared. Use setImage when you want to also set the imageSource.

warning

This property is writable but has no undo!

since

1.9

imageFileName

imageFileName: string

Reference to the image rendered by this layer.

since

1.11

imageSource

imageSource: QUrl

Reference to the image rendered by this layer.

If you need a plain string, you'll want to use imageFileName instead.

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

Readonly map

map: null | TileMap

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

name

name: string

Name of the 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).

parallaxFactor

parallaxFactor: point

The parallax factor of this layer.

Readonly parentLayer

parentLayer: null | GroupLayer

The group layer this layer is part of, or null in case the layer is not grouped.

Readonly readOnly

readOnly: boolean

Whether the object is read-only.

repeatX

repeatX: boolean

Whether the image rendered by this layer repeats along the X axis.

since

1.8

repeatY

repeatY: boolean

Whether the image rendered by this layer repeats along the Y axis.

since

1.8

selected

selected: boolean

Whether the layer is selected.

tintColor

tintColor: color

Tint color of the layer. Will be used to tint any images rendered by this layer or by any child layers. Affects tile layers, image layers and tile objects.

Since Tiled 1.8.5, this property is #ffffff when no tint color has been set on this layer (before it was #000000 in that case).

since

1.8

transparentColor

transparentColor: color

Color used as transparent color when rendering the image.

visible

visible: boolean

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

Static Readonly GroupLayerType

GroupLayerType: number

Static Readonly ImageLayerType

ImageLayerType: number

Static Readonly ObjectGroupType

ObjectGroupType: number

Static Readonly TileLayerType

TileLayerType: number

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 for this layer to the given image, optionally also setting its file name. The existing image file name is cleared.

    warning

    This function has no undo!

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, 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