Phaser API Documentation

  Version: 
<static> FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer)

Description:

Find the first tile in the given rectangular area (in tile coordinates) of the layer that satisfies the provided testing function. I.e. finds the first tile for which callback returns true. Similar to Array.prototype.find in vanilla JS.

Parameters:

name type description
callback FindTileCallback

The callback. Each tile in the given area will be passed to this callback as the first and only parameter.

context object

The context under which the callback should be run.

tileX number

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

tileY number

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

width number

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

height number

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

filteringOptions Phaser.Types.Tilemaps.FilteringOptions

Optional filters to apply when getting the tiles.

layer Phaser.Tilemaps.LayerData

The Tilemap Layer to act upon.

Returns:
Description:

A Tile that matches the search, or null if no Tile found

Since: 3.0.0