You’re reading the docs for Phaser v3.90.0. The latest is Phaser v4.1.0.

Phaser.Physics.Arcade.Components.Gravity

Scope: static

Source: src/physics/arcade/components/Gravity.js#L7
Since: 3.0.0

Static functions

setGravity

instancesetGravity(x, [y])

Description:

Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect.

If only one value is provided, this value will be used for both the X and Y axis.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe gravitational force to be applied to the X-axis.
ynumberYes"x"The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used.

Returns: Phaser.Physics.Arcade.Components.Gravity - This Game Object.

Source: src/physics/arcade/components/Gravity.js#L16
Since: 3.0.0


setGravityX

instancesetGravityX(x)

Description:

Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect.

Parameters:

nametypeoptionaldescription
xnumberNoThe gravitational force to be applied to the X-axis.

Returns: Phaser.Physics.Arcade.Components.Gravity - This Game Object.

Source: src/physics/arcade/components/Gravity.js#L36
Since: 3.0.0


setGravityY

instancesetGravityY(y)

Description:

Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect.

Parameters:

nametypeoptionaldescription
ynumberNoThe gravitational force to be applied to the Y-axis.

Returns: Phaser.Physics.Arcade.Components.Gravity - This Game Object.

Source: src/physics/arcade/components/Gravity.js#L53
Since: 3.0.0