Phaser API Documentation

  Version: 
filterTiles(callback, [context], [tileX], [tileY], [width], [height], [filteringOptions], [layer])

Description:

For each tile in the given rectangular area (in tile coordinates) of the layer, run the given filter callback function. Any tiles that pass the filter test (i.e. where the callback returns true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. If no layer specified, the map's current layer is used.

Parameters:

name type arguments description
callback function

The callback. Each tile in the given area will be passed to this callback as the first and only parameter. The callback should return true for tiles that pass the filter.

context object <optional>

The context under which the callback should be run.

tileX number <optional>

The left most tile index (in tile coordinates) to use as the origin of the area to filter.

tileY number <optional>

The top most tile index (in tile coordinates) to use as the origin of the area to filter.

width number <optional>

How many tiles wide from the tileX index the area will be.

height number <optional>

How many tiles tall from the tileY index the area will be.

filteringOptions Phaser.Types.Tilemaps.FilteringOptions <optional>

Optional filters to apply when getting the tiles.

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

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

Returns:
Description:

Returns an array of Tiles, or null if the layer given was invalid.

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