Home Reference Source Repository

Function

Static Public Summary
public

phaserTiledHull(tilemapLayer: Phaser.TilemapLayer, options: object): Array<PolygonEdge[]>

A function to take a tilemap layer and process its tiles into clusters.

Static Public

public phaserTiledHull(tilemapLayer: Phaser.TilemapLayer, options: object): Array<PolygonEdge[]> source

import phaserTiledHull from 'phaser-tiled-hull/library/tiled-hull.js'

A function to take a tilemap layer and process its tiles into clusters. This returns an array of polygons - each polygon encloses a separate cluster of tiles in the tilemap layer.

Params:

NameTypeAttributeDescription
tilemapLayer Phaser.TilemapLayer

The tilemap layer to use for hull calculation.

options object
  • optional
  • default: {}

Options for filtering the tiles and only allowing certain tiles to be added to the final hulls. If no options specified, then all tiles in the layer will be processed and added to a hull. If multiple options are specified, then a tile only has to match ONE of the options to be added to a hull.

options.tileIndices number[]
  • optional
  • default: null

An array of tile indices to use for determining which tiles should be clustered together. If a tile's index matches an index in the array, it will be added to a hull.

options.tileProperty string
  • optional
  • default: null

The name of a property on tiles (set in Tiled) to use for determining which tiles should be clustered together. If the property is true (or truthy) on a tile, it will be added to a hull.

options.checkCollide boolean
  • optional
  • default: false

Whether or not a tile's collide property should be used for determining which tiles should be clustered together. If true, then colliding tiles will be added to a hull.

Return:

Array<PolygonEdge[]>

An array where each element represents a polygon. The polygons are stored as an array of PolygonEdge instances.