Namespace: Origin

Phaser.GameObjects.Components. Origin

Provides methods used for getting and setting the origin of a Game Object. Values are normalized, given in the range 0 to 1. Display values contain the calculated pixel values. Should be applied as a mixin and not used directly.

Since: 3.0.0
Source: src/gameobjects/components/Origin.js (Line 7)

Members


displayOriginX :number

The horizontal display origin of this Game Object. The origin is a normalized value between 0 and 1. The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/components/Origin.js (Line 60)

displayOriginY :number

The vertical display origin of this Game Object. The origin is a normalized value between 0 and 1. The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/components/Origin.js (Line 84)

originX :number

The horizontal origin of this Game Object. The origin maps the relationship between the size and position of the Game Object. The default value is 0.5, meaning all Game Objects are positioned based on their center. Setting the value to 0 means the position now relates to the left of the Game Object.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0.5
Source: src/gameobjects/components/Origin.js (Line 30)

originY :number

The vertical origin of this Game Object. The origin maps the relationship between the size and position of the Game Object. The default value is 0.5, meaning all Game Objects are positioned based on their center. Setting the value to 0 means the position now relates to the top of the Game Object.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0.5
Source: src/gameobjects/components/Origin.js (Line 43)

Methods


setDisplayOrigin( [x] [, y])

Sets the display origin of this Game Object. The difference between this and setting the origin is that you can use pixel values for setting the display origin.

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

The horizontal display origin value.

y number <optional>
x

The vertical display origin value. If not defined it will be set to the value of x.

Since: 3.0.0
Source: src/gameobjects/components/Origin.js (Line 155)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.Origin

setOrigin( [x] [, y])

Sets the origin of this Game Object.

The values are given in the range 0 to 1.

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

The horizontal origin value.

y number <optional>
x

The vertical origin value. If not defined it will be set to the value of x.

Since: 3.0.0
Source: src/gameobjects/components/Origin.js (Line 108)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.Origin

setOriginFromFrame()

Sets the origin of this Game Object based on the Pivot values in its Frame.

Since: 3.0.0
Source: src/gameobjects/components/Origin.js (Line 132)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.Origin

updateDisplayOrigin()

Updates the Display Origin cached values internally stored on this Game Object. You don't usually call this directly, but it is exposed for edge-cases where you may.

Since: 3.0.0
Source: src/gameobjects/bitmaptext/static/BitmapText.js (Line 385)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.Origin

updateDisplayOrigin()

Updates the Display Origin cached values internally stored on this Game Object. You don't usually call this directly, but it is exposed for edge-cases where you may.

Since: 3.0.0
Source: src/gameobjects/components/Origin.js (Line 178)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.Origin