Options
All
  • Public
  • Public/Protected
  • All
Menu

A world defined in a .world file, which is a JSON file that tells Tiled which maps are part of the world and at what location.

See the Working with Worlds page in the manual for more information.

since

1.11

Hierarchy

Index

Constructors

constructor

Properties

Readonly asset

asset: null | Asset

The asset this object is part of, or null.

Readonly assetType

assetType: AssetType

The type of this asset.

since

1.11

className

className: string

Class name of the object.

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

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.

Readonly isTileMap

isTileMap: boolean

Whether the asset is a TileMap.

Readonly isTileset

isTileset: boolean

Whether the asset is a Tileset.

Readonly maps

The maps that are explicitly added to this world. It does not include those maps which match due to patterns defined on the world.

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.

Readonly patterns

patterns: WorldPattern[]

The patterns that are configured for this map. These patterns will be used to automatically match maps in your project.

Readonly readOnly

readOnly: boolean

Whether the object is read-only.

Methods

addMap

  • addMap(fileName: string, rect: rect): void
  • addMap(map: TileMap, x: number, y: number): void
  • Add a map to this world.

  • Add a map to this world. The map size in pixels will be set automatically.

allMaps

  • Returns all maps that are part of this world, either directly referenced or matched by one of the patterns.

containsMap

  • containsMap(fileName: string): boolean
  • containsMap(map: TileMap): boolean
  • Returns true if this world contains a map with the given fileName.

  • Returns true if this world contains the given map.

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.

mapsInRect

  • Returns any maps that intersect with the given rect. This is a filtered version of the results from allMaps.

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!

removeMap

  • removeMap(fileName: string): void
  • removeMap(map: TileMap): void
  • Remove a map from this world.

  • Remove a map from this world.

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.

save

  • save(): boolean
  • Save this asset to disk. Returns true if the asset was saved successfully.

    Errors are reported by the UI. When an editor is open for this asset, this editor is activated when an error is reported.

    Only supported with the editor running, not when running scripts on the CLI. Also, the asset should already have an associated file.

    To save assets to a specific file or in a different format, use tiled.mapFormat or tiled.tilesetFormat. This is currently not supported for worlds.

    since

    1.11

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

setMapPos

  • setMapPos(map: TileMap, x: number, y: number): void
  • Change the position of a map within this world.

setMapRect

  • setMapRect(fileName: string, rect: rect): void
  • Change the position and size of a map within this world.

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

undo

  • undo(): void
  • Undoes the last applied change.

    note

    The undo system is only enabled for assets loaded in the editor!

Generated using TypeDoc