TiledTile Component References

The TiledTile component can operate on a particular map block individually.

tiledtile-component

Creation Method

Create via Editor

Create an empty node under the Layer node automatically generated during the creation of the TiledMap component. Then select the empty node and click Add component -> TiledMap -> TiledTile under the Inspector panel to add the TiledTile component to the node. Then you can manipulate the map block by setting the properties on the TiledTile component.

add_tiledtile

For related TiledTile script interface, please refer to the TiledTile API.

Create by Code

There are two ways to set up a map block in code. When setting the TiledTile in a Layer node, the TiledTile at the original location of that Layer node will be replaced.

Create by adding a TiledTile Ccmponent to a node

  1. // Create a new node
  2. const node = new Node();
  3. // then set the node's parent to any layer node
  4. node.parent = this.layer.node;
  5. // Finally add the TiledTile component to the node and return the TiledTile object, which allows you to perform a series of operations on the TiledTile object
  6. const tiledTile = node.addComponent(TiledTile);

Get TiledTile by getTiledTileAt

  1. // Get the TiledTile object on the layer with horizontal coordinates of 0 and vertical coordinates of 0. You can then perform a series of operations on the TiledTile object
  2. const tiledTile = this.layer.getTiledTileAt(0, 0);

For the Layer script interface, please refer to the TiledLayer API.

TiledTile Properties

PropertyDescription
XSpecifies the horizontal coordinates of the TiledTile, in map blocks
YSpecifies the vertical coordinates of the TiledTile, in map blocks
GidSpecifies the gid value of the TiledTile to toggle the style of the TiledTile

TiledTile can control the specified map block and apply the displacement, rotation and scaling of nodes to the map block. The user can change the map block style by changing the gid property of the TiledTile.

Note: the gid can only be used with an existing map block in the map to toggle the style of the map block, it is not possible to toggle the style of the map block by customizing the Sprite Frame.

Node properties that can be applied to TiledTile

PropertyDescription
PositionChange the Position of the specified TiledTile
RotationRotate the specified TiledTile
ScaleScale the specified TiledTile
ColorChange the Color of the specified TiledTile
OpacityAdjust the Opacity of the specified TiledTile
SkewAdjust the Skew of the specified TiledTile