Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord
Namespace: Bounds
Phaser.Display.Bounds

Methods

<static> CenterOn(gameObject, x, y)
Focus
Focus

Description:

Positions the Game Object so that it is centered on the given coordinates.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object that will be re-positioned.

x number

The horizontal coordinate to position the Game Object on.

y number

The vertical coordinate to position the Game Object on.

Returns:
Description:

The Game Object that was positioned.

Examples:
Since: 3.0.0
Focus
Focus
<static> GetBottom(gameObject)
Focus
Focus

Description:

Returns the bottom coordinate from the bounds of the Game Object.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object to get the bounds value from.

Returns:
Description:

The bottom coordinate of the bounds of the Game Object.

Type:
  • number
Examples:
Since: 3.0.0
Focus
Focus
<static> GetBounds(gameObject, [output])
Focus
Focus

Description:

Returns the unrotated bounds of the Game Object as a rectangle.

Parameters:

name type arguments description
gameObject Phaser.GameObjects.GameObject

The Game Object to get the bounds value from.

output object | Phaser.Geom.Rectangle <optional>

An object to store the values in.

Returns:
Description:
  • The bounds of the Game Object.
Type:
Examples:
Since: 3.24.0
Focus
Focus
<static> GetCenterX(gameObject)
Focus
Focus

Description:

Returns the center x coordinate from the bounds of the Game Object.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object to get the bounds value from.

Returns:
Description:

The center x coordinate of the bounds of the Game Object.

Type:
  • number
Examples:
Since: 3.0.0
Focus
Focus
<static> GetCenterY(gameObject)
Focus
Focus

Description:

Returns the center y coordinate from the bounds of the Game Object.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object to get the bounds value from.

Returns:
Description:

The center y coordinate of the bounds of the Game Object.

Type:
  • number
Examples:
Since: 3.0.0
Focus
Focus
<static> GetLeft(gameObject)
Focus
Focus

Description:

Returns the left coordinate from the bounds of the Game Object.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object to get the bounds value from.

Returns:
Description:

The left coordinate of the bounds of the Game Object.

Type:
  • number
Examples:
Since: 3.0.0
Focus
Focus
<static> GetOffsetX(gameObject)
Focus
Focus

Description:

Returns the amount the Game Object is visually offset from its x coordinate. This is the same as width * origin.x. This value will only be > 0 if origin.x is not equal to zero.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object to get the bounds value from.

Returns:
Description:

The horizontal offset of the Game Object.

Type:
  • number
Examples:
Since: 3.0.0
Focus
Focus
<static> GetOffsetY(gameObject)
Focus
Focus

Description:

Returns the amount the Game Object is visually offset from its y coordinate. This is the same as width * origin.y. This value will only be > 0 if origin.y is not equal to zero.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object to get the bounds value from.

Returns:
Description:

The vertical offset of the Game Object.

Type:
  • number
Examples:
Since: 3.0.0
Focus
Focus
<static> GetRight(gameObject)
Focus
Focus

Description:

Returns the right coordinate from the bounds of the Game Object.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object to get the bounds value from.

Returns:
Description:

The right coordinate of the bounds of the Game Object.

Type:
  • number
Examples:
Since: 3.0.0
Focus
Focus
<static> GetTop(gameObject)
Focus
Focus

Description:

Returns the top coordinate from the bounds of the Game Object.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object to get the bounds value from.

Returns:
Description:

The top coordinate of the bounds of the Game Object.

Type:
  • number
Examples:
Since: 3.0.0
Focus
Focus
<static> SetBottom(gameObject, value)
Focus
Focus

Description:

Positions the Game Object so that the bottom of its bounds aligns with the given coordinate.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object that will be re-positioned.

value number

The coordinate to position the Game Object bounds on.

Returns:
Description:

The Game Object that was positioned.

Examples:
Since: 3.0.0
Focus
Focus
<static> SetCenterX(gameObject, x)
Focus
Focus

Description:

Positions the Game Object so that the center top of its bounds aligns with the given coordinate.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object that will be re-positioned.

x number

The coordinate to position the Game Object bounds on.

Returns:
Description:

The Game Object that was positioned.

Examples:
Since: 3.0.0
Focus
Focus
<static> SetCenterY(gameObject, y)
Focus
Focus

Description:

Positions the Game Object so that the center top of its bounds aligns with the given coordinate.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object that will be re-positioned.

y number

The coordinate to position the Game Object bounds on.

Returns:
Description:

The Game Object that was positioned.

Examples:
Since: 3.0.0
Focus
Focus
<static> SetLeft(gameObject, value)
Focus
Focus

Description:

Positions the Game Object so that the left of its bounds aligns with the given coordinate.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object that will be re-positioned.

value number

The coordinate to position the Game Object bounds on.

Returns:
Description:

The Game Object that was positioned.

Examples:
Since: 3.0.0
Focus
Focus
<static> SetRight(gameObject, value)
Focus
Focus

Description:

Positions the Game Object so that the left of its bounds aligns with the given coordinate.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object that will be re-positioned.

value number

The coordinate to position the Game Object bounds on.

Returns:
Description:

The Game Object that was positioned.

Examples:
Since: 3.0.0
Focus
Focus
<static> SetTop(gameObject, value)
Focus
Focus

Description:

Positions the Game Object so that the top of its bounds aligns with the given coordinate.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

The Game Object that will be re-positioned.

value number

The coordinate to position the Game Object bounds on.

Returns:
Description:

The Game Object that was positioned.

Examples:
Since: 3.0.0
Focus
Focus