Phaser API Documentation

setCollisionFromCollisionGroup([collides], [recalculateFaces], [layer])


Sets collision on the tiles within a layer by checking each tiles collision group data (typically defined in Tiled within the tileset collision editor). If any objects are found within a tiles collision group, the tiles colliding information will be set. The collides parameter controls if collision will be enabled (true) or disabled (false).

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


name type arguments description
collides boolean <optional>

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

recalculateFaces boolean <optional>

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

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

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


Return this Tilemap object, or null if the layer given was invalid.

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