Phaser API Documentation

  Version: 

Member of: Phaser.Geom.Line

<static> GetEasedPoints(line, ease, quantity, [collinearThreshold], [easeParams])

Description:

Returns an array of quantity Points where each point is taken from the given Line, spaced out according to the ease function specified.

const line = new Phaser.Geom.Line(100, 300, 700, 300);
const points = Phaser.Geom.Line.GetEasedPoints(line, 'sine.out', 32)

In the above example, the points array will contain 32 points spread-out across the length of line, where the position of each point is determined by the Sine.out ease function.

You can optionally provide a collinear threshold. In this case, the resulting points are checked against each other, and if they are < collinearThreshold distance apart, they are dropped from the results. This can help avoid lots of clustered points at far ends of the line with tightly-packed eases such as Quartic. Leave the value set to zero to skip this check.

Note that if you provide a collinear threshold, the resulting array may not always contain quantity points.

Parameters:

name type arguments description
line Phaser.Geom.Line

The Line object.

ease string | function

The ease to use. This can be either a string from the EaseMap, or a custom function.

quantity number

The number of points to return. Note that if you provide a collinearThreshold, the resulting array may not always contain this number of points.

collinearThreshold number <optional>

An optional threshold. The final array is reduced so that each point is spaced out at least this distance apart. This helps reduce clustering in noisey eases.

easeParams Array.<number> <optional>

An optional array of ease parameters to go with the ease.

Returns:
Description:

An array of Geom.Points containing the coordinates of the points on the line.

Type:
Since: 3.23.0