Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface TileLayerWangEdit

This object enables modifying the tiles on a tile layer using a WangSet. For performance reasons, the changes are not applied directly. Call either the apply or generate function when you're done making changes.

Note that the result may vary since the changes are applied by looking for tiles matching the desired Wang colors, which includes a random factor in case of multiple matches.

Colors in a WangSet are numbered starting from 1. To request no Wang color, usually for Wang-aware erasing, use 0. The currently selected WangSet and color are available through MapEditor.currentWangSet and MapEditor.currentWangColorIndex.

An instance of this object is created by calling TileLayer.wangEdit.

since

1.10.2

Hierarchy

  • TileLayerWangEdit

Index

Properties

correctionsEnabled

correctionsEnabled: boolean

Whether neighboring tiles will be corrected to match up with any marked changes once apply is called. This can cause a larger area to get modified. Defaults to false.

erasingEnabled

erasingEnabled: boolean

Whether the empty tile is considered when looking for matching tiles. Defaults to true.

mergeable

mergeable: boolean

Whether applied edits are mergeable with previous edits. Starts out as false and is automatically set to true by apply.

Readonly target

target: TileLayer

The target layer of this edit object.

Readonly wangSet

wangSet: WangSet

The Wang set that will be used when apply or generate is called.

Methods

apply

  • apply(): void
  • Applies the changes made through this object to the target layer. This object can be reused to make further changes.

    Alternatively, get a copy of the modifications using generate.

generate

  • Applies the changes made through this object to a new layer and returns that layer. This object can be reused to make further changes.

    example

    Making a change and use the result for Tool.preview:

    let wangSet = tiled.mapEditor.currentWangSet
    let wangEdit = tiled.activeAsset.currentLayer.wangEdit(wangSet)
    wangEdit.correctionsEnabled = true
    wangEdit.setCorner(this.tilePosition, tiled.mapEditor.currentWangColorIndex)
    let map = new TileMap()
    map.addLayer(wangEdit.generate())
    this.preview = map
    

    Alternatively, you can apply the changes directly to the target layer using apply.

setCorner

  • setCorner(x: number, y: number, color: number): void
  • setCorner(pos: point, color: number): void
  • Sets the desired color for the given corner at the given vertex location.

    The vertex location refers to a point in between the tiles, where (0, 0) is the top-left corner of the map and (mapWidth, mapHeight) is the bottom-right corner.

    Changing the color of a corner affects all 4 tiles meeting at that corner.

  • Sets the desired color for the given corner at the given vertex location.

    The vertex location refers to a point in between the tiles, where (0, 0) is the top-left corner of the map and (mapWidth, mapHeight) is the bottom-right corner.

    Changing the color of a corner affects all 4 tiles meeting at that corner.

setEdge

  • setEdge(x: number, y: number, edge: WangIndex, color: number): void
  • setEdge(pos: point, edge: WangIndex, color: number): void

setWangIndex

  • setWangIndex(x: number, y: number, wangIndex: WangIndex, color: number): void
  • setWangIndex(pos: point, wangIndex: WangIndex, color: number): void
  • Sets the desired color for the given Wang index at the given location.

    This is a low-level function, which only affects the given location and does not automatically adjust any neighboring tiles. Use setCorner or setEdge when that is desired or set correctionsEnabled to true.

  • Sets the desired color for the given Wang index at the given location.

    This is a low-level function, which only affects the given location and does not automatically adjust any neighboring tiles. Use setCorner or setEdge when that is desired or set correctionsEnabled to true.

Generated using TypeDoc