Class: Point

Phaser.Geom. Point

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


new Point( [x] [, y])

Parameters:
Name Type Argument Default Description
x number <optional>
0

The x coordinate of this Point.

y number <optional>
x

The y coordinate of this Point.

Since: 3.0.0
Source: src/geom/point/Point.js (Line 10)

Members


<readonly> type :number

The geometry constant type of this object: GEOM_CONST.POINT. Used for fast type comparisons.

Type:
  • number
Since: 3.19.0
Source: src/geom/point/Point.js (Line 31)

x :number

The x coordinate of this Point.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/geom/point/Point.js (Line 42)

y :number

The y coordinate of this Point.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/geom/point/Point.js (Line 52)

Methods


<static> Ceil(point)

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

Parameters:
Name Type Description
point Phaser.Geom.Point

The Point to ceil.

Since: 3.0.0
Source: src/geom/point/Ceil.js (Line 7)
Returns:

The Point with Math.ceil() applied to its coordinates.

Type
Phaser.Geom.Point

<static> Clone(source)

Clone the given Point.

Parameters:
Name Type Description
source Phaser.Geom.Point

The source Point to clone.

Since: 3.0.0
Source: src/geom/point/Clone.js (Line 9)
Returns:

The cloned Point.

Type
Phaser.Geom.Point

<static> CopyFrom(source, dest)

Copy the values of one Point to a destination Point.

Parameters:
Name Type Description
source Phaser.Geom.Point

The source Point to copy the values from.

dest Phaser.Geom.Point

The destination Point to copy the values to.

Since: 3.0.0
Source: src/geom/point/CopyFrom.js (Line 7)
Returns:

The destination Point.

Type
Phaser.Geom.Point

<static> Equals(point, toCompare)

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

Parameters:
Name Type Description
point Phaser.Geom.Point

The original Point to compare against.

toCompare Phaser.Geom.Point

The second Point to compare.

Since: 3.0.0
Source: src/geom/point/Equals.js (Line 7)
Returns:

Returns true if the both Point objects are equal.

Type
boolean

<static> Floor(point)

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

Parameters:
Name Type Description
point Phaser.Geom.Point

The Point to floor.

Since: 3.0.0
Source: src/geom/point/Floor.js (Line 7)
Returns:

The Point with Math.floor() applied to its coordinates.

Type
Phaser.Geom.Point

<static> GetCentroid(points [, out])

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.

Parameters:
Name Type Argument Description
points Array.<Phaser.Types.Math.Vector2Like>

An array of Vector2Like objects to get the geometric center of.

out Phaser.Geom.Point <optional>

A Point object to store the output coordinates in. If not given, a new Point instance is created.

Since: 3.0.0
Source: src/geom/point/GetCentroid.js (Line 9)
Returns:

A Point object representing the geometric center of the given points.

Type
Phaser.Geom.Point

<static> GetMagnitude(point)

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

Parameters:
Name Type Description
point Phaser.Geom.Point

The point to calculate the magnitude for

Since: 3.0.0
Source: src/geom/point/GetMagnitude.js (Line 7)
Returns:

The resulting magnitude

Type
number

<static> GetMagnitudeSq(point)

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

Parameters:
Name Type Description
point Phaser.Geom.Point

Returns square of the magnitude/length of given point.

Since: 3.0.0
Source: src/geom/point/GetMagnitudeSq.js (Line 7)
Returns:

Returns square of the magnitude of given point.

Type
number

<static> GetRectangleFromPoints(points [, out])

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

Parameters:
Name Type Argument Description
points Array.<Phaser.Types.Math.Vector2Like>

An array of Vector2Like objects to get the AABB from.

out Phaser.Geom.Rectangle <optional>

A Rectangle object to store the results in. If not given, a new Rectangle instance is created.

Since: 3.0.0
Source: src/geom/point/GetRectangleFromPoints.js (Line 9)
Returns:

A Rectangle object holding the AABB values for the given points.

Type
Phaser.Geom.Rectangle

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

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

Parameters:
Name Type Argument Default Description
pointA Phaser.Geom.Point

The starting Point for the interpolation.

pointB Phaser.Geom.Point

The target Point for the interpolation.

t number <optional>
0

The 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.

out Phaser.Geom.Point | object <optional>

An 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.

Since: 3.0.0
Source: src/geom/point/Interpolate.js (Line 9)
Returns:

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.

Type
Phaser.Geom.Point | object

<static> Invert(point)

Swaps the X and the Y coordinate of a point.

Parameters:
Name Type Description
point Phaser.Geom.Point

The Point to modify.

Since: 3.0.0
Source: src/geom/point/Invert.js (Line 7)
Returns:

The modified point.

Type
Phaser.Geom.Point

<static> Negative(point [, out])

Inverts a Point's coordinates.

Parameters:
Name Type Argument Description
point Phaser.Geom.Point

The Point to invert.

out Phaser.Geom.Point <optional>

The Point to return the inverted coordinates in.

Since: 3.0.0
Source: src/geom/point/Negative.js (Line 9)
Returns:

The modified out Point, or a new Point if none was provided.

Type
Phaser.Geom.Point

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

Calculates the vector projection of pointA onto the nonzero pointB. This is the orthogonal projection of pointA onto a straight line paralle to pointB.

Parameters:
Name Type Argument Description
pointA Phaser.Geom.Point

Point A, to be projected onto Point B.

pointB Phaser.Geom.Point

Point B, to have Point A projected upon it.

out Phaser.Geom.Point <optional>

The Point object to store the position in. If not given, a new Point instance is created.

Since: 3.0.0
Source: src/geom/point/Project.js (Line 10)
Returns:

A Point object holding the coordinates of the vector projection of pointA onto pointB.

Type
Phaser.Geom.Point

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

Calculates the vector projection of pointA onto the nonzero pointB. This is the orthogonal projection of pointA onto a straight line paralle to pointB.

Parameters:
Name Type Argument Description
pointA Phaser.Geom.Point

Point A, to be projected onto Point B. Must be a normalized point with a magnitude of 1.

pointB Phaser.Geom.Point

Point B, to have Point A projected upon it.

out Phaser.Geom.Point <optional>

The Point object to store the position in. If not given, a new Point instance is created.

Since: 3.0.0
Source: src/geom/point/ProjectUnit.js (Line 9)
Returns:

A unit Point object holding the coordinates of the vector projection of pointA onto pointB.

Type
Phaser.Geom.Point

<static> SetMagnitude(point, magnitude)

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

Parameters:
Name Type Description
point Phaser.Geom.Point

The Point to treat as the end point of the vector.

magnitude number

The new magnitude of the vector.

Since: 3.0.0
Source: src/geom/point/SetMagnitude.js (Line 9)
Returns:

The modified Point.

Type
Phaser.Geom.Point

setTo( [x] [, y])

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

Parameters:
Name Type Argument Default Description
x number <optional>
0

The x coordinate of this Point.

y number <optional>
x

The y coordinate of this Point.

Since: 3.0.0
Source: src/geom/point/Point.js (Line 63)
Returns:

This Point object.

Type
Phaser.Geom.Point