Phaser API Documentation

putTilesAt(tile, tileX, tileY, [recalculateFaces], [layer])


Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified layer. The array can be composed of either tile indexes or Tile objects. 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 within the region tiles were changed.

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


name type arguments description
tile Array.<number> | Array.<Array.<number>> | Array.<Phaser.Tilemaps.Tile> | Array.<Array.<Phaser.Tilemaps.Tile>>

A row (array) or grid (2D array) of Tiles or tile indexes to place.

tileX number

The x coordinate, in tiles, not pixels.

tileY number

The y coordinate, in tiles, not pixels.

recalculateFaces boolean <optional>

true if the faces data should be recalculated.

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

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


Returns this, or null if the layer given was invalid.

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