Phaser.Physics.Arcade.Components.Gravity
Scope: static
Source: src/physics/arcade/components/Gravity.js#L7
Since: 3.0.0
Static functions
setGravity
<instance> setGravity(x, [y])
Description:
Sets the body gravity for both the X and Y axes. This is an acceleration applied to this body in addition to the world gravity, in pixels per second squared. Values can be positive or negative. Larger absolute values result in a stronger effect.
If only one value is provided, it will be used for both the X and Y axes.
Parameters:
| name | type | optional | default | description |
|---|---|---|---|---|
| x | number | No | The gravitational acceleration to be applied to the X-axis, in pixels per second squared. | |
| y | number | Yes | "x" | The gravitational acceleration to be applied to the Y-axis, in pixels per second squared. If not specified, the X value will be used. |
Returns: Phaser.Physics.Arcade.Components.Gravity - This Game Object.
Source: src/physics/arcade/components/Gravity.js#L23
Since: 3.0.0
setGravityX
<instance> setGravityX(x)
Description:
Sets the body gravity applied to the X-axis. This is an acceleration in addition to the world gravity, in pixels per second squared. Use a positive value to pull the body to the right and a negative value to pull it to the left.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| x | number | No | The gravitational acceleration to be applied to the X-axis, in pixels per second squared. |
Returns: Phaser.Physics.Arcade.Components.Gravity - This Game Object.
Source: src/physics/arcade/components/Gravity.js#L45
Since: 3.0.0
setGravityY
<instance> setGravityY(y)
Description:
Sets the body gravity applied to the Y-axis. This is an acceleration in addition to the world gravity, in pixels per second squared. Use a positive value to pull the body downward and a negative value to push it upward (against gravity).
Parameters:
| name | type | optional | description |
|---|---|---|---|
| y | number | No | The gravitational acceleration to be applied to the Y-axis, in pixels per second squared. |
Returns: Phaser.Physics.Arcade.Components.Gravity - This Game Object.
Source: src/physics/arcade/components/Gravity.js#L64
Since: 3.0.0