Skip to main content
Version: Phaser v4.0.0

Phaser.Physics.Arcade.Components.Bounce

Scope: static

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

Static functions

setBounce

<instance> setBounce(x, [y])

Description:

Sets the bounce values of this body.

Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe amount of horizontal bounce to apply on collision. A float, typically between 0 and 1.
ynumberYes"x"The amount of vertical bounce to apply on collision. A float, typically between 0 and 1.

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

Source: src/physics/arcade/components/Bounce.js#L15
Since: 3.0.0


setBounceX

<instance> setBounceX(value)

Description:

Sets the horizontal bounce value for this body. This is the amount of restitution applied on the x-axis when the body collides with another object. A value of 1 retains full horizontal velocity after the rebound. A value of 0 means no horizontal bounce at all.

Parameters:

nametypeoptionaldescription
valuenumberNoThe amount of horizontal bounce to apply on collision. A float, typically between 0 and 1.

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

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


setBounceY

<instance> setBounceY(value)

Description:

Sets the vertical bounce value for this body. This is the amount of restitution applied on the y-axis when the body collides with another object. A value of 1 retains full vertical velocity after the rebound. A value of 0 means no vertical bounce at all.

Parameters:

nametypeoptionaldescription
valuenumberNoThe amount of vertical bounce to apply on collision. A float, typically between 0 and 1.

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

Source: src/physics/arcade/components/Bounce.js#L55
Since: 3.0.0


setCollideWorldBounds

<instance> setCollideWorldBounds([value], [bounceX], [bounceY], [onWorldBounds])

Description:

Sets whether this Body collides with the world boundary.

Optionally also sets the World Bounce values. If the Body.worldBounce is null, it's set to a new Phaser.Math.Vector2 first.

Parameters:

nametypeoptionaldefaultdescription
valuebooleanYestruetrue if this body should collide with the world bounds, otherwise false.
bounceXnumberYesIf given, this will replace the worldBounce.x value.
bounceYnumberYesIf given, this will replace the worldBounce.y value.
onWorldBoundsbooleanYesIf given this replaces the Body's onWorldBounds value.

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

Source: src/physics/arcade/components/Bounce.js#L74
Since: 3.0.0