Phaser API Documentation

putTileAtWorldXY(tile, worldX, worldY, [recalculateFaces], [camera], [layer])


Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified location. If you pass in an index, only the index at the specified location will be changed. Collision information will be recalculated at the specified location.

If no layer is specified, the maps current layer is used.


name type arguments description
tile number | Phaser.Tilemaps.Tile

The index of this tile to set or a Tile object.

worldX number

The x coordinate, in pixels.

worldY number

The y coordinate, in pixels.

recalculateFaces boolean <optional>

true if the faces data should be recalculated.

camera Phaser.Cameras.Scene2D.Camera <optional>

The Camera to use when calculating the tile index from the world values.

layer string | number | Phaser.Tilemaps.TilemapLayer <optional>

The tile layer to use. If not given the current layer is used.


Returns a Tile, or null if the layer given was invalid.

Since: 3.0.0
Source: src/tilemaps/Tilemap.js (Line 1573)