Skip to main content
Version: Phaser v3.88.2

Point

Defines a Point in 2D space, with an x and y component.

Constructor

new Point([x], [y])

Parameters

nametypeoptionaldefaultdescription
xnumberYes0The x coordinate of this Point.
ynumberYes"x"The y coordinate of this Point.

Scope: static

Source: src/geom/point/Point.js#L10
Since: 3.0.0

Public Methods

Ceil

<static> Ceil(point)

Description:

Apply Math.ceil() to each coordinate of the given Point.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
pointPhaser.Geom.PointNoThe Point to ceil.

Returns: Phaser.Geom.Point - The Point with Math.ceil() applied to its coordinates.

Source: src/geom/point/Ceil.js#L7
Since: 3.0.0


Clone

<static> Clone(source)

Description:

Clone the given Point.

Parameters:

nametypeoptionaldescription
sourcePhaser.Geom.PointNoThe source Point to clone.

Returns: Phaser.Geom.Point - The cloned Point.

Source: src/geom/point/Clone.js#L9
Since: 3.0.0


CopyFrom

<static> CopyFrom(source, dest)

Description:

Copy the values of one Point to a destination Point.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
sourcePhaser.Geom.PointNoThe source Point to copy the values from.
destPhaser.Geom.PointNoThe destination Point to copy the values to.

Returns: Phaser.Geom.Point - The destination Point.

Source: src/geom/point/CopyFrom.js#L7
Since: 3.0.0


Equals

<static> Equals(point, toCompare)

Description:

A comparison of two Point objects to see if they are equal.

Parameters:

nametypeoptionaldescription
pointPhaser.Geom.PointNoThe original Point to compare against.
toComparePhaser.Geom.PointNoThe second Point to compare.

Returns: boolean - Returns true if the both Point objects are equal.

Source: src/geom/point/Equals.js#L7
Since: 3.0.0


Floor

<static> Floor(point)

Description:

Apply Math.ceil() to each coordinate of the given Point.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
pointPhaser.Geom.PointNoThe Point to floor.

Returns: Phaser.Geom.Point - The Point with Math.floor() applied to its coordinates.

Source: src/geom/point/Floor.js#L7
Since: 3.0.0


GetCentroid

<static> GetCentroid(points, [out])

Description:

Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure).

Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
pointsArray.<Phaser.Types.Math.Vector2Like>NoAn array of Vector2Like objects to get the geometric center of.
outPhaser.Geom.PointYesA Point object to store the output coordinates in. If not given, a new Point instance is created.

Returns: Phaser.Geom.Point - A Point object representing the geometric center of the given points.

Source: src/geom/point/GetCentroid.js#L9
Since: 3.0.0


GetMagnitude

<static> GetMagnitude(point)

Description:

Calculate the magnitude of the point, which equivalent to the length of the line from the origin to this point.

Parameters:

nametypeoptionaldescription
pointPhaser.Geom.PointNoThe point to calculate the magnitude for

Returns: number - The resulting magnitude

Source: src/geom/point/GetMagnitude.js#L7
Since: 3.0.0


GetMagnitudeSq

<static> GetMagnitudeSq(point)

Description:

Calculates the square of magnitude of given point.(Can be used for fast magnitude calculation of point)

Parameters:

nametypeoptionaldescription
pointPhaser.Geom.PointNoReturns square of the magnitude/length of given point.

Returns: number - Returns square of the magnitude of given point.

Source: src/geom/point/GetMagnitudeSq.js#L7
Since: 3.0.0


GetRectangleFromPoints

<static> GetRectangleFromPoints(points, [out])

Description:

Calculates the Axis Aligned Bounding Box (or aabb) from an array of points.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
pointsArray.<Phaser.Types.Math.Vector2Like>NoAn array of Vector2Like objects to get the AABB from.
outPhaser.Geom.RectangleYesA Rectangle object to store the results in. If not given, a new Rectangle instance is created.

Returns: Phaser.Geom.Rectangle - A Rectangle object holding the AABB values for the given points.

Source: src/geom/point/GetRectangleFromPoints.js#L9
Since: 3.0.0


Interpolate

<static> Interpolate(pointA, pointB, [t], [out])

Description:

Returns the linear interpolation point between the two given points, based on t.

Tags:

  • generic

Parameters:

nametypeoptionaldefaultdescription
pointAPhaser.Geom.PointNoThe starting Point for the interpolation.
pointBPhaser.Geom.PointNoThe target Point for the interpolation.
tnumberYes0The amount to interpolate between the two points. Generally, a value between 0 (returns the starting Point) and 1 (returns the target Point). If omitted, 0 is used.
outPhaser.Geom.Point | objectYesAn optional Point object whose x and y values will be set to the result of the interpolation (can also be any object with x and y properties). If omitted, a new Point created and returned.

Returns: Phaser.Geom.Point, object - Either the object from the out argument with the properties x and y set to the result of the interpolation or a newly created Point object.

Source: src/geom/point/Interpolate.js#L9
Since: 3.0.0


Invert

<static> Invert(point)

Description:

Swaps the X and the Y coordinate of a point.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
pointPhaser.Geom.PointNoThe Point to modify.

Returns: Phaser.Geom.Point - The modified point.

Source: src/geom/point/Invert.js#L7
Since: 3.0.0


Negative

<static> Negative(point, [out])

Description:

Inverts a Point's coordinates.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
pointPhaser.Geom.PointNoThe Point to invert.
outPhaser.Geom.PointYesThe Point to return the inverted coordinates in.

Returns: Phaser.Geom.Point - The modified out Point, or a new Point if none was provided.

Source: src/geom/point/Negative.js#L9
Since: 3.0.0


Project

<static> Project(pointA, pointB, [out])

Description:

Calculates the vector projection of pointA onto the nonzero pointB. This is the

orthogonal projection of pointA onto a straight line parallel to pointB.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
pointAPhaser.Geom.PointNoPoint A, to be projected onto Point B.
pointBPhaser.Geom.PointNoPoint B, to have Point A projected upon it.
outPhaser.Geom.PointYesThe Point object to store the position in. If not given, a new Point instance is created.

Returns: Phaser.Geom.Point - A Point object holding the coordinates of the vector projection of pointA onto pointB.

Source: src/geom/point/Project.js#L10
Since: 3.0.0


ProjectUnit

<static> ProjectUnit(pointA, pointB, [out])

Description:

Calculates the vector projection of pointA onto the nonzero pointB. This is the

orthogonal projection of pointA onto a straight line paralle to pointB.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
pointAPhaser.Geom.PointNoPoint A, to be projected onto Point B. Must be a normalized point with a magnitude of 1.
pointBPhaser.Geom.PointNoPoint B, to have Point A projected upon it.
outPhaser.Geom.PointYesThe Point object to store the position in. If not given, a new Point instance is created.

Returns: Phaser.Geom.Point - A unit Point object holding the coordinates of the vector projection of pointA onto pointB.

Source: src/geom/point/ProjectUnit.js#L9
Since: 3.0.0


SetMagnitude

<static> SetMagnitude(point, magnitude)

Description:

Changes the magnitude (length) of a two-dimensional vector without changing its direction.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
pointPhaser.Geom.PointNoThe Point to treat as the end point of the vector.
magnitudenumberNoThe new magnitude of the vector.

Returns: Phaser.Geom.Point - The modified Point.

Source: src/geom/point/SetMagnitude.js#L9
Since: 3.0.0


setTo

<instance> setTo([x], [y])

Description:

Set the x and y coordinates of the point to the given values.

Parameters:

nametypeoptionaldefaultdescription
xnumberYes0The x coordinate of this Point.
ynumberYes"x"The y coordinate of this Point.

Returns: Phaser.Geom.Point - This Point object.

Source: src/geom/point/Point.js#L63
Since: 3.0.0


Public Members

type

type: number

Description:

The geometry constant type of this object: GEOM_CONST.POINT.

Used for fast type comparisons.

Source: src/geom/point/Point.js#L31
Since: 3.19.0


x

x: number

Description:

The x coordinate of this Point.

Source: src/geom/point/Point.js#L42
Since: 3.0.0


y

y: number

Description:

The y coordinate of this Point.

Source: src/geom/point/Point.js#L52
Since: 3.0.0