Phaser API Documentation

<static> SetCollision(indexes, collides, recalculateFaces, layer, [updateLayer])


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).


name type arguments Default description
indexes number | array

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

collides boolean

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

recalculateFaces boolean

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

layer Phaser.Tilemaps.LayerData

The Tilemap Layer to act upon.

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.

Since: 3.0.0