Class: Rectangle

Phaser. Rectangle

Phaser.Rectangle

new Rectangle(x, y, width, height) → {Rectangle}

Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created.

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.

Source:
Returns:

This Rectangle object.

Type
Rectangle

Members

bottom

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.

Properties:
Name Type Description
bottom number

The sum of the y and height properties.

Source:

bottom

The location of the Rectangles bottom right corner as a Point object.

Properties:
Name Type Description
bottomRight Phaser.Point

Gets or sets the location of the Rectangles bottom right corner as a Point object.

Source:

centerX

The x coordinate of the center of the Rectangle.

Properties:
Name Type Description
centerX number

The x coordinate of the center of the Rectangle.

Source:

centerY

The y coordinate of the center of the Rectangle.

Properties:
Name Type Description
centerY number

The y coordinate of the center of the Rectangle.

Source:

empty

Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is less than or equal to 0. If set to true then all of the Rectangle properties are set to 0.

Properties:
Name Type Description
empty boolean

Gets or sets the Rectangles empty state.

Source:

<readonly> halfHeight

Properties:
Name Type Description
halfHeight number

Half of the height of the Rectangle.

Source:

<readonly> halfWidth

Properties:
Name Type Description
halfWidth number

Half of the width of the Rectangle.

Source:

height

Properties:
Name Type Description
height number

The height of the Rectangle.

Source:

left

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.

Properties:
Name Type Description
left number

The x coordinate of the left of the Rectangle.

Source:

<readonly> perimeter

The perimeter size of the Rectangle. This is the sum of all 4 sides.

Properties:
Name Type Description
perimeter number

The perimeter size of the Rectangle. This is the sum of all 4 sides.

Source:

The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property.

Properties:
Name Type Description
right number

The sum of the x and width properties.

Source:

top

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.

Properties:
Name Type Description
top number

The y coordinate of the top of the Rectangle.

Source:

topLeft

The location of the Rectangles top left corner as a Point object.

Properties:
Name Type Description
topLeft Phaser.Point

The location of the Rectangles top left corner as a Point object.

Source:

<readonly> volume

The volume of the Rectangle derived from width * height.

Properties:
Name Type Description
volume number

The volume of the Rectangle derived from width * height.

Source:

width

Properties:
Name Type Description
width number

The width of the Rectangle.

Source:

x

Properties:
Name Type Description
x number

The x coordinate of the top-left corner of the Rectangle.

Source:

y

Properties:
Name Type Description
y number

The y coordinate of the top-left corner of the Rectangle.

Source:

Methods

<static> clone(a, output) → {Phaser.Rectangle}

Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.

Parameters:
Name Type Argument Description
a Phaser.Rectangle

The Rectangle object.

output Phaser.Rectangle <optional>

Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.

Source:
Returns:
Type
Phaser.Rectangle

<static> contains(a, x, y) → {boolean}

Determines whether the specified coordinates are contained within the region defined by this Rectangle object.

Parameters:
Name Type Description
a Phaser.Rectangle

The Rectangle object.

x number

The x coordinate of the point to test.

y number

The y coordinate of the point to test.

Source:
Returns:

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

Type
boolean

<static> containsPoint(a, point) → {boolean}

Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.

Parameters:
Name Type Description
a Phaser.Rectangle

The Rectangle object.

point Phaser.Point

The point object being checked. Can be Point or any object with .x and .y values.

Source:
Returns:

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

Type
boolean

<static> containsRect(a, b) → {boolean}

Determines whether the first Rectangle object is fully contained within the second Rectangle object. A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.

Parameters:
Name Type Description
a Phaser.Rectangle

The first Rectangle object.

b Phaser.Rectangle

The second Rectangle object.

Source:
Returns:

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

Type
boolean

<static> equals(a, b) → {boolean}

Determines whether the two Rectangles are equal. This method compares the x, y, width and height properties of each Rectangle.

Parameters:
Name Type Description
a Phaser.Rectangle

The first Rectangle object.

b Phaser.Rectangle

The second Rectangle object.

Source:
Returns:

A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.

Type
boolean

<static> inflate(a, dx, dy) → {Phaser.Rectangle}

Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.

Parameters:
Name Type Description
a Phaser.Rectangle

The Rectangle object.

dx number

The amount to be added to the left side of the Rectangle.

dy number

The amount to be added to the bottom side of the Rectangle.

Source:
Returns:

This Rectangle object.

Type
Phaser.Rectangle

<static> inflatePoint(a, point) → {Phaser.Rectangle}

Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter.

Parameters:
Name Type Description
a Phaser.Rectangle

The Rectangle object.

point Phaser.Point

The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object.

Source:
Returns:

The Rectangle object.

Type
Phaser.Rectangle

<static> intersection(a, b, out) → {Phaser.Rectangle}

If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.

Parameters:
Name Type Argument Description
a Phaser.Rectangle

The first Rectangle object.

b Phaser.Rectangle

The second Rectangle object.

out Phaser.Rectangle <optional>

Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.

Source:
Returns:

A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0.

Type
Phaser.Rectangle

<static> intersects(a, b) → {boolean}

Determines whether the two Rectangles intersect with each other. This method checks the x, y, width, and height properties of the Rectangles.

Parameters:
Name Type Description
a Phaser.Rectangle

The first Rectangle object.

b Phaser.Rectangle

The second Rectangle object.

Source:
Returns:

A value of true if the specified object intersects with this Rectangle object; otherwise false.

Type
boolean

<static> intersectsRaw(left, right, top, bottom, tolerance) → {boolean}

Determines whether the object specified intersects (overlaps) with the given values.

Parameters:
Name Type Description
left number

Description.

right number

Description.

top number

Description.

bottom number

Description.

tolerance number

A tolerance value to allow for an intersection test with padding, default to 0

Source:
Returns:

A value of true if the specified object intersects with the Rectangle; otherwise false.

Type
boolean

<static> size(a, output) → {Phaser.Point}

The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.

Parameters:
Name Type Argument Description
a Phaser.Rectangle

The Rectangle object.

output Phaser.Point <optional>

Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.

Source:
Returns:

The size of the Rectangle object

Type
Phaser.Point

<static> union(a, b, out) → {Phaser.Rectangle}

Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles.

Parameters:
Name Type Argument Description
a Phaser.Rectangle

The first Rectangle object.

b Phaser.Rectangle

The second Rectangle object.

out Phaser.Rectangle <optional>

Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.

Source:
Returns:

A Rectangle object that is the union of the two Rectangles.

Type
Phaser.Rectangle

clone(output) → {Phaser.Rectangle}

Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.

Parameters:
Name Type Argument Description
output Phaser.Rectangle <optional>

Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.

Source:
Returns:
Type
Phaser.Rectangle

contains(x, y) → {boolean}

Determines whether the specified coordinates are contained within the region defined by this Rectangle object.

Parameters:
Name Type Description
x number

The x coordinate of the point to test.

y number

The y coordinate of the point to test.

Source:
Returns:

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

Type
boolean

containsRect(b) → {boolean}

Determines whether the first Rectangle object is fully contained within the second Rectangle object. A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.

Parameters:
Name Type Description
b Phaser.Rectangle

The second Rectangle object.

Source:
Returns:

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

Type
boolean

copyFrom(source) → {Rectangle}

Copies the x, y, width and height properties from any given object to this Rectangle.

Parameters:
Name Type Description
source any

The object to copy from.

Source:
Returns:

This Rectangle object.

Type
Rectangle

copyTo(source) → {object}

Copies the x, y, width and height properties from this Rectangle to any given object.

Parameters:
Name Type Description
source any

The object to copy to.

Source:
Returns:

This object.

Type
object

equals(b) → {boolean}

Determines whether the two Rectangles are equal. This method compares the x, y, width and height properties of each Rectangle.

Parameters:
Name Type Description
b Phaser.Rectangle

The second Rectangle object.

Source:
Returns:

A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.

Type
boolean

floor()

Runs Math.floor() on both the x and y values of this Rectangle.

Source:

floorAll()

Runs Math.floor() on the x, y, width and height values of this Rectangle.

Source:

inflate(dx, dy) → {Phaser.Rectangle}

Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.

Parameters:
Name Type Description
dx number

The amount to be added to the left side of the Rectangle.

dy number

The amount to be added to the bottom side of the Rectangle.

Source:
Returns:

This Rectangle object.

Type
Phaser.Rectangle

intersection(b, out) → {Phaser.Rectangle}

If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.

Parameters:
Name Type Description
b Phaser.Rectangle

The second Rectangle object.

out Phaser.Rectangle

Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.

Source:
Returns:

A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0.

Type
Phaser.Rectangle

intersects(b, tolerance) → {boolean}

Determines whether the two Rectangles intersect with each other. This method checks the x, y, width, and height properties of the Rectangles.

Parameters:
Name Type Description
b Phaser.Rectangle

The second Rectangle object.

tolerance number

A tolerance value to allow for an intersection test with padding, default to 0.

Source:
Returns:

A value of true if the specified object intersects with this Rectangle object; otherwise false.

Type
boolean

intersectsRaw(left, right, top, bottomt, tolerance) → {boolean}

Determines whether the object specified intersects (overlaps) with the given values.

Parameters:
Name Type Description
left number

Description.

right number

Description.

top number

Description.

bottomt number

Description.

tolerance number

A tolerance value to allow for an intersection test with padding, default to 0

Source:
Returns:

A value of true if the specified object intersects with the Rectangle; otherwise false.

Type
boolean

offset(dx, dy) → {Rectangle}

Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.

Parameters:
Name Type Description
dx number

Moves the x value of the Rectangle object by this amount.

dy number

Moves the y value of the Rectangle object by this amount.

Source:
Returns:

This Rectangle object.

Type
Rectangle

offsetPoint(point) → {Rectangle}

Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter.

Parameters:
Name Type Description
point Point

A Point object to use to offset this Rectangle object.

Source:
Returns:

This Rectangle object.

Type
Rectangle

setTo(x, y, width, height) → {Rectangle}

Sets the members of Rectangle to the specified values.

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 in pixels.

height number

The height of the Rectangle in pixels.

Source:
Returns:

This Rectangle object

Type
Rectangle

size(output) → {Phaser.Point}

The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.

Parameters:
Name Type Argument Description
output Phaser.Point <optional>

Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.

Source:
Returns:

The size of the Rectangle object.

Type
Phaser.Point

toString() → {string}

Returns a string representation of this object.

Source:
Returns:

A string representation of the instance.

Type
string

union(b, out) → {Phaser.Rectangle}

Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles.

Parameters:
Name Type Argument Description
b Phaser.Rectangle

The second Rectangle object.

out Phaser.Rectangle <optional>

Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.

Source:
Returns:

A Rectangle object that is the union of the two Rectangles.

Type
Phaser.Rectangle
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Wed Feb 05 2014 06:28:33 GMT-0000 (GMT) using the DocStrap template.