Phaser API Documentation

  Version: 
setCollision(indexes, [collides], [recalculateFaces], [updateLayer])

Description:

Sets collision on the given tile or tiles within a layer by index. You can pass in either a single numeric index or an array of indexes: [2, 3, 15, 20]. The collides parameter controls if collision will be enabled (true) or disabled (false).

Parameters:

name type arguments Default description
indexes number | array

Either a single tile index, or an array of tile indexes.

collides boolean <optional> true

If true it will enable collision. If false it will clear collision.

recalculateFaces boolean <optional> true

Whether or not to recalculate the tile faces after the update.

updateLayer boolean <optional> true

If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost.

Returns:
Description:

This Tilemap Layer object.

Since: 3.50.0