Phaser API Documentation

  Version: 
Filter

Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height)

Constructor:

new Rectangle([x], [y], [width], [height])

Parameters:

name type arguments description
x number <optional>

The X coordinate of the top left corner of the Rectangle.

y number <optional>

The Y coordinate of the top left corner of the Rectangle.

width number <optional>

The width of the Rectangle.

height number <optional>

The height of the Rectangle.

Since: 3.0.0

Members

bottom: number
Focus
Focus

Description:

The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.

Type:
number
Since: 3.0.0
Focus
Focus
centerX: number
Focus
Focus

Description:

The x coordinate of the center of the Rectangle.

Type:
number
Since: 3.0.0
Focus
Focus
centerY: number
Focus
Focus

Description:

The y coordinate of the center of the Rectangle.

Type:
number
Since: 3.0.0
Focus
Focus
height: number
Focus
Focus

Description:

The height of the Rectangle, i.e. the distance between its top side (defined by y) and its bottom side.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
left: number
Focus
Focus

Description:

The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property.

Type:
number
Since: 3.0.0
Focus
Focus
top: number
Focus
Focus

Description:

The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. However it does affect the height property, whereas changing the y value does not affect the height property.

Type:
number
Since: 3.0.0
Focus
Focus
<readonly> type: number
Focus
Focus

Description:

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

Type:
number
Since: 3.19.0
Focus
Focus
width: number
Focus
Focus

Description:

The width of the Rectangle, i.e. the distance between its left side (defined by x) and its right side.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
x: number
Focus
Focus

Description:

The X coordinate of the top left corner of the Rectangle.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
y: number
Focus
Focus

Description:

The Y coordinate of the top left corner of the Rectangle.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus

Methods

contains(x, y)
Focus
Focus

Description:

Checks if the given point is inside the Rectangle's bounds.

Parameters:

name type description
x number

The X coordinate of the point to check.

y number

The Y coordinate of the point to check.

Returns:
Description:

true if the point is within the Rectangle's bounds, otherwise false.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
getLineA([line])
Focus
Focus

Description:

Returns a Line object that corresponds to the top of this Rectangle.

Parameters:

name type arguments description
line Phaser.Geom.Line <optional>

A Line object to set the results in. If undefined a new Line will be created.

Returns:
Description:

A Line object that corresponds to the top of this Rectangle.

Since: 3.0.0
Focus
Focus
getLineB([line])
Focus
Focus

Description:

Returns a Line object that corresponds to the right of this Rectangle.

Parameters:

name type arguments description
line Phaser.Geom.Line <optional>

A Line object to set the results in. If undefined a new Line will be created.

Returns:
Description:

A Line object that corresponds to the right of this Rectangle.

Since: 3.0.0
Focus
Focus
getLineC([line])
Focus
Focus

Description:

Returns a Line object that corresponds to the bottom of this Rectangle.

Parameters:

name type arguments description
line Phaser.Geom.Line <optional>

A Line object to set the results in. If undefined a new Line will be created.

Returns:
Description:

A Line object that corresponds to the bottom of this Rectangle.

Since: 3.0.0
Focus
Focus
getLineD([line])
Focus
Focus

Description:

Returns a Line object that corresponds to the left of this Rectangle.

Parameters:

name type arguments description
line Phaser.Geom.Line <optional>

A Line object to set the results in. If undefined a new Line will be created.

Returns:
Description:

A Line object that corresponds to the left of this Rectangle.

Since: 3.0.0
Focus
Focus
getPoint(position, [output])
Focus
Focus

Description:

Calculates the coordinates of a point at a certain position on the Rectangle's perimeter.

The position is a fraction between 0 and 1 which defines how far into the perimeter the point is.

A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side.

Parameters:

name type arguments description
position number

The normalized distance into the Rectangle's perimeter to return.

output object | Phaser.Geom.Point <optional>

An object to update with the x and y coordinates of the point.

Returns:
Description:

The updated output object, or a new Point if no output object was given.

Type:
Since: 3.0.0
Focus
Focus
getPoints(quantity, [stepRate], [output])
Focus
Focus

Description:

Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required.

Parameters:

name type arguments description
quantity number

The number of points to return. Set to false or 0 to return an arbitrary number of points (perimeter / stepRate) evenly spaced around the Rectangle based on the stepRate.

stepRate number <optional>

If quantity is 0, determines the normalized distance between each returned point.

output array | Array.<Phaser.Geom.Point> <optional>

An array to which to append the points.

Returns:
Description:

The modified output array, or a new array if none was provided.

Type:
Since: 3.0.0
Focus
Focus
getRandomPoint([point])
Focus
Focus

Description:

Returns a random point within the Rectangle's bounds.

Parameters:

name type arguments description
point Phaser.Geom.Point <optional>

The object in which to store the x and y coordinates of the point.

Returns:
Description:

The updated point, or a new Point if none was provided.

Since: 3.0.0
Focus
Focus
isEmpty()
Focus
Focus

Description:

Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0.

Returns:
Description:

true if the Rectangle is empty. A Rectangle object is empty if its width or height is less than or equal to 0.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
setEmpty()
Focus
Focus

Description:

Resets the position, width, and height of the Rectangle to 0.

Returns:
Description:

This Rectangle object.

Since: 3.0.0
Focus
Focus
setPosition(x, [y])
Focus
Focus

Description:

Sets the position of the Rectangle.

Parameters:

name type arguments Default description
x number

The X coordinate of the top left corner of the Rectangle.

y number <optional> x

The Y coordinate of the top left corner of the Rectangle.

Returns:
Description:

This Rectangle object.

Since: 3.0.0
Focus
Focus
setSize(width, [height])
Focus
Focus

Description:

Sets the width and height of the Rectangle.

Parameters:

name type arguments Default description
width number

The width to set the Rectangle to.

height number <optional> width

The height to set the Rectangle to.

Returns:
Description:

This Rectangle object.

Since: 3.0.0
Focus
Focus
setTo(x, y, width, height)
Focus
Focus

Description:

Sets the position, width, and height of the Rectangle.

Parameters:

name type description
x number

The X coordinate of the top left corner of the Rectangle.

y number

The Y coordinate of the top left corner of the Rectangle.

width number

The width of the Rectangle.

height number

The height of the Rectangle.

Returns:
Description:

This Rectangle object.

Since: 3.0.0
Focus
Focus
<static> Area(rect)
Focus
Focus

Description:

Calculates the area of the given Rectangle object.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The rectangle to calculate the area of.

Returns:
Description:

The area of the Rectangle object.

Type:
  • number
Since: 3.0.0
Source: src/geom/rectangle/Area.js (Line 7)
Focus
Focus
<static> Ceil(rect)
Focus
Focus

Description:

Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to adjust.

Returns:
Description:

The adjusted Rectangle.

Since: 3.0.0
Source: src/geom/rectangle/Ceil.js (Line 7)
Focus
Focus
<static> CeilAll(rect)
Focus
Focus

Description:

Rounds a Rectangle's position and size up to the smallest integer greater than or equal to each respective value.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to modify.

Returns:
Description:

The modified Rectangle.

Since: 3.0.0
Focus
Focus
<static> CenterOn(rect, x, y)
Focus
Focus

Description:

Moves the top-left corner of a Rectangle so that its center is at the given coordinates.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to be centered.

x number

The X coordinate of the Rectangle's center.

y number

The Y coordinate of the Rectangle's center.

Returns:
Description:

The centered rectangle.

Since: 3.0.0
Focus
Focus
<static> Clone(source)
Focus
Focus

Description:

Creates a new Rectangle which is identical to the given one.

Parameters:

name type description
source Phaser.Geom.Rectangle

The Rectangle to clone.

Returns:
Description:

The newly created Rectangle, which is separate from the given one.

Since: 3.0.0
Focus
Focus
<static> Contains(rect, x, y)
Focus
Focus

Description:

Checks if a given point is inside a Rectangle's bounds.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to check.

x number

The X coordinate of the point to check.

y number

The Y coordinate of the point to check.

Returns:
Description:

true if the point is within the Rectangle's bounds, otherwise false.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
<static> ContainsPoint(rect, point)
Focus
Focus

Description:

Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle object.

point Phaser.Geom.Point

The point object to be checked. Can be a Phaser Point object or any object with x and y values.

Returns:
Description:

A value of true if the Rectangle object contains the specified point, otherwise false.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
<static> ContainsRect(rectA, rectB)
Focus
Focus

Description:

Tests if one rectangle fully contains another.

Parameters:

name type description
rectA Phaser.Geom.Rectangle

The first rectangle.

rectB Phaser.Geom.Rectangle

The second rectangle.

Returns:
Description:

True only if rectA fully contains rectB.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
<static> CopyFrom(source, dest)
Focus
Focus

Description:

Copy the values of one Rectangle to a destination Rectangle.

Parameters:

name type description
source Phaser.Geom.Rectangle

The source Rectangle to copy the values from.

dest Phaser.Geom.Rectangle

The destination Rectangle to copy the values to.

Returns:
Description:

The destination Rectangle.

Since: 3.0.0
Focus
Focus
<static> Decompose(rect, [out])
Focus
Focus

Description:

Create an array of points for each corner of a Rectangle If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created.

Parameters:

name type arguments description
rect Phaser.Geom.Rectangle

The Rectangle object to be decomposed.

out array <optional>

If provided, each point will be added to this array.

Returns:
Description:

Will return the array you specified or a new array containing the points of the Rectangle.

Type:
  • array
Since: 3.0.0
Focus
Focus
<static> Equals(rect, toCompare)
Focus
Focus

Description:

Compares the x, y, width and height properties of two rectangles.

Parameters:

name type description
rect Phaser.Geom.Rectangle

Rectangle A

toCompare Phaser.Geom.Rectangle

Rectangle B

Returns:
Description:

true if the rectangles' properties are an exact match, otherwise false.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
<static> FitInside(target, source)
Focus
Focus

Description:

Adjusts the target rectangle, changing its width, height and position, so that it fits inside the area of the source rectangle, while maintaining its original aspect ratio.

Unlike the FitOutside function, there may be some space inside the source area not covered.

Parameters:

name type description
target Phaser.Geom.Rectangle

The target rectangle to adjust.

source Phaser.Geom.Rectangle

The source rectangle to envelop the target in.

Returns:
Description:

The modified target rectangle instance.

Since: 3.0.0
Focus
Focus
<static> FitOutside(target, source)
Focus
Focus

Description:

Adjusts the target rectangle, changing its width, height and position, so that it fully covers the area of the source rectangle, while maintaining its original aspect ratio.

Unlike the FitInside function, the target rectangle may extend further out than the source.

Parameters:

name type description
target Phaser.Geom.Rectangle

The target rectangle to adjust.

source Phaser.Geom.Rectangle

The source rectangle to envelope the target in.

Returns:
Description:

The modified target rectangle instance.

Since: 3.0.0
Focus
Focus
<static> Floor(rect)
Focus
Focus

Description:

Rounds down (floors) the top left X and Y coordinates of the given Rectangle to the largest integer less than or equal to them

Parameters:

name type description
rect Phaser.Geom.Rectangle

The rectangle to floor the top left X and Y coordinates of

Returns:
Description:

The rectangle that was passed to this function with its coordinates floored.

Since: 3.0.0
Focus
Focus
<static> FloorAll(rect)
Focus
Focus

Description:

Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to adjust.

Returns:
Description:

The adjusted Rectangle.

Since: 3.0.0
Focus
Focus
<static> FromPoints(points, [out])
Focus
Focus

Description:

Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds.

Parameters:

name type arguments description
points array

An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public x and y properties) which should be surrounded by the Rectangle.

out Phaser.Geom.Rectangle <optional>

Optional Rectangle to adjust.

Returns:
Description:

The adjusted out Rectangle, or a new Rectangle if none was provided.

Since: 3.0.0
Focus
Focus
<static> FromXY(x1, y1, x2, y2, [out])
Focus
Focus

Description:

Create the smallest Rectangle containing two coordinate pairs.

Parameters:

name type arguments description
x1 number

The X coordinate of the first point.

y1 number

The Y coordinate of the first point.

x2 number

The X coordinate of the second point.

y2 number

The Y coordinate of the second point.

out Phaser.Geom.Rectangle <optional>

Optional Rectangle to adjust.

Returns:
Description:

The adjusted out Rectangle, or a new Rectangle if none was provided.

Since: 3.23.0
Focus
Focus
<static> GetAspectRatio(rect)
Focus
Focus

Description:

Calculates the width/height ratio of a rectangle.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The rectangle.

Returns:
Description:

The width/height ratio of the rectangle.

Type:
  • number
Since: 3.0.0
Focus
Focus
<static> GetCenter(rect, [out])
Focus
Focus

Description:

Returns the center of a Rectangle as a Point.

Parameters:

name type arguments description
rect Phaser.Geom.Rectangle

The Rectangle to get the center of.

out object | Phaser.Geom.Point <optional>

Optional point-like object to update with the center coordinates.

Returns:
Description:

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

Type:
Since: 3.0.0
Focus
Focus
<static> GetPoint(rectangle, position, [out])
Focus
Focus

Description:

Calculates the coordinates of a point at a certain position on the Rectangle's perimeter.

The position is a fraction between 0 and 1 which defines how far into the perimeter the point is.

A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side.

Parameters:

name type arguments description
rectangle Phaser.Geom.Rectangle

The Rectangle to get the perimeter point from.

position number

The normalized distance into the Rectangle's perimeter to return.

out object | Phaser.Geom.Point <optional>

An object to update with the x and y coordinates of the point.

Returns:
Description:

The updated output object, or a new Point if no output object was given.

Since: 3.0.0
Focus
Focus
<static> GetPoints(rectangle, step, quantity, [out])
Focus
Focus

Description:

Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required.

Parameters:

name type arguments description
rectangle Phaser.Geom.Rectangle

The Rectangle object to get the points from.

step number

Step between points. Used to calculate the number of points to return when quantity is falsey. Ignored if quantity is positive.

quantity number

The number of evenly spaced points from the rectangles perimeter to return. If falsey, step param will be used to calculate the number of points.

out array | Array.<Phaser.Geom.Point> <optional>

An optional array to store the points in.

Returns:
Description:

An array of Points from the perimeter of the rectangle.

Type:
Since: 3.0.0
Focus
Focus
<static> GetSize(rect, [out])
Focus
Focus

Description:

Returns the size of the Rectangle, expressed as a Point object. With the value of the width as the x property and the height as the y property.

Parameters:

name type arguments description
rect Phaser.Geom.Rectangle

The Rectangle to get the size from.

out object | Phaser.Geom.Point <optional>

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

Returns:
Description:

A Point object where x holds the width and y holds the height of the Rectangle.

Type:
Since: 3.0.0
Focus
Focus
<static> Inflate(rect, x, y)
Focus
Focus

Description:

Increases the size of a Rectangle by a specified amount.

The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to inflate.

x number

How many pixels the left and the right side should be moved by horizontally.

y number

How many pixels the top and the bottom side should be moved by vertically.

Returns:
Description:

The inflated Rectangle.

Since: 3.0.0
Focus
Focus
<static> Intersection(rectA, rectB, [out])
Focus
Focus

Description:

Takes two Rectangles and first checks to see if they intersect. If they intersect it will return the area of intersection in the out Rectangle. If they do not intersect, the out Rectangle will have a width and height of zero.

Parameters:

name type arguments description
rectA Phaser.Geom.Rectangle

The first Rectangle to get the intersection from.

rectB Phaser.Geom.Rectangle

The second Rectangle to get the intersection from.

out Phaser.Geom.Rectangle <optional>

A Rectangle to store the intersection results in.

Returns:
Description:

The intersection result. If the width and height are zero, no intersection occurred.

Since: 3.11.0
Focus
Focus
<static> MarchingAnts(rect, [step], [quantity], [out])
Focus
Focus

Description:

Returns an array of points from the perimeter of the Rectangle, where each point is spaced out based on either the step value, or the quantity.

Parameters:

name type arguments description
rect Phaser.Geom.Rectangle

The Rectangle to get the perimeter points from.

step number <optional>

The distance between each point of the perimeter. Set to null if you wish to use the quantity parameter instead.

quantity number <optional>

The total number of points to return. The step is then calculated based on the length of the Rectangle, divided by this value.

out array | Array.<Phaser.Geom.Point> <optional>

An array in which the perimeter points will be stored. If not given, a new array instance is created.

Returns:
Description:

An array containing the perimeter points from the Rectangle.

Type:
Since: 3.0.0
Focus
Focus
<static> MergePoints(target, points)
Focus
Focus

Description:

Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds.

Parameters:

name type description
target Phaser.Geom.Rectangle

The Rectangle which should be merged.

points Array.<Phaser.Geom.Point>

An array of Points (or any object with public x and y properties) which should be merged with the Rectangle.

Returns:
Description:

The modified Rectangle.

Since: 3.0.0
Focus
Focus
<static> MergeRect(target, source)
Focus
Focus

Description:

Merges the source rectangle into the target rectangle and returns the target. Neither rectangle should have a negative width or height.

Parameters:

name type description
target Phaser.Geom.Rectangle

Target rectangle. Will be modified to include source rectangle.

source Phaser.Geom.Rectangle

Rectangle that will be merged into target rectangle.

Returns:
Description:

Modified target rectangle that contains source rectangle.

Since: 3.0.0
Focus
Focus
<static> MergeXY(target, x, y)
Focus
Focus

Description:

Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds.

Parameters:

name type description
target Phaser.Geom.Rectangle

The Rectangle which should be merged and modified.

x number

The X coordinate of the point which should be merged.

y number

The Y coordinate of the point which should be merged.

Returns:
Description:

The modified target Rectangle.

Since: 3.0.0
Focus
Focus
<static> Offset(rect, x, y)
Focus
Focus

Description:

Nudges (translates) the top left corner of a Rectangle by a given offset.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to adjust.

x number

The distance to move the Rectangle horizontally.

y number

The distance to move the Rectangle vertically.

Returns:
Description:

The adjusted Rectangle.

Since: 3.0.0
Focus
Focus
<static> OffsetPoint(rect, point)
Focus
Focus

Description:

Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector).

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to adjust.

point Phaser.Geom.Point | Phaser.Math.Vector2

The point whose coordinates should be used as an offset.

Returns:
Description:

The adjusted Rectangle.

Since: 3.0.0
Focus
Focus
<static> Overlaps(rectA, rectB)
Focus
Focus

Description:

Checks if two Rectangles overlap. If a Rectangle is within another Rectangle, the two will be considered overlapping. Thus, the Rectangles are treated as "solid".

Parameters:

name type description
rectA Phaser.Geom.Rectangle

The first Rectangle to check.

rectB Phaser.Geom.Rectangle

The second Rectangle to check.

Returns:
Description:

true if the two Rectangles overlap, false otherwise.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
<static> Perimeter(rect)
Focus
Focus

Description:

Calculates the perimeter of a Rectangle.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to use.

Returns:
Description:

The perimeter of the Rectangle, equal to (width * 2) + (height * 2).

Type:
  • number
Since: 3.0.0
Focus
Focus
<static> PerimeterPoint(rectangle, angle, [out])
Focus
Focus

Description:

Returns a Point from the perimeter of a Rectangle based on the given angle.

Parameters:

name type arguments description
rectangle Phaser.Geom.Rectangle

The Rectangle to get the perimeter point from.

angle number

The angle of the point, in degrees.

out Phaser.Geom.Point <optional>

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

Returns:
Description:

A Point object holding the coordinates of the Rectangle perimeter.

Since: 3.0.0
Focus
Focus
<static> Random(rect, out)
Focus
Focus

Description:

Returns a random point within a Rectangle.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle to return a point from.

out Phaser.Geom.Point

The object to update with the point's coordinates.

Returns:
Description:

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

Since: 3.0.0
Focus
Focus
<static> RandomOutside(outer, inner, [out])
Focus
Focus

Description:

Calculates a random point that lies within the outer Rectangle, but outside of the inner Rectangle. The inner Rectangle must be fully contained within the outer rectangle.

Parameters:

name type arguments description
outer Phaser.Geom.Rectangle

The outer Rectangle to get the random point within.

inner Phaser.Geom.Rectangle

The inner Rectangle to exclude from the returned point.

out Phaser.Geom.Point <optional>

A Point, or Point-like object to store the result in. If not specified, a new Point will be created.

Returns:
Description:

A Point object containing the random values in its x and y properties.

Since: 3.10.0
Focus
Focus
<static> SameDimensions(rect, toCompare)
Focus
Focus

Description:

Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The first Rectangle object.

toCompare Phaser.Geom.Rectangle

The second Rectangle object.

Returns:
Description:

true if the objects have equivalent values for the width and height properties, otherwise false.

Type:
  • boolean
Since: 3.15.0
Focus
Focus
<static> Scale(rect, x, y)
Focus
Focus

Description:

Scales the width and height of this Rectangle by the given amounts.

Parameters:

name type description
rect Phaser.Geom.Rectangle

The Rectangle object that will be scaled by the specified amount(s).

x number

The factor by which to scale the rectangle horizontally.

y number

The amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor x in both directions.

Returns:
Description:

The rectangle object with updated width and height properties as calculated from the scaling factor(s).

Since: 3.0.0
Focus
Focus
<static> Union(rectA, rectB, [out])
Focus
Focus

Description:

Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union.

Parameters:

name type arguments description
rectA Phaser.Geom.Rectangle

The first Rectangle to use.

rectB Phaser.Geom.Rectangle

The second Rectangle to use.

out Phaser.Geom.Rectangle <optional>

The Rectangle to store the union in.

Returns:
Description:

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

Since: 3.0.0
Focus
Focus