Skip to main content
Version: Phaser v4.0.0-rc.6

GravityWell

The Gravity Well Particle Processor applies a force on the particles to draw

them towards, or repel them from, a single point.

The force applied is inversely proportional to the square of the distance

from the particle to the point, in accordance with Newton's law of gravity.

This simulates the effect of gravity over large distances (as between planets, for example).

Constructor

new GravityWell([x], [y], [power], [epsilon], [gravity])

Parameters

nametypeoptionaldefaultdescription
xnumber | Phaser.Types.GameObjects.Particles.GravityWellConfigYes0The x coordinate of the Gravity Well, in world space.
ynumberYes0The y coordinate of the Gravity Well, in world space.
powernumberYes0The strength of the gravity force - larger numbers produce a stronger force.
epsilonnumberYes100The minimum distance for which the gravity force is calculated.
gravitynumberYes50The gravitational force of this Gravity Well.

Scope: static

Extends

Phaser.GameObjects.Particles.ParticleProcessor

Source: src/gameobjects/particles/GravityWell.js#L11
Since: 3.0.0

Inherited Members

From Phaser.GameObjects.Particles.ParticleProcessor:


Public Members

epsilon

epsilon: number

Description:

The minimum distance for which the gravity force is calculated.

Defaults to 100.

Source: src/gameobjects/particles/GravityWell.js#L129
Since: 3.0.0


gravity

gravity: number

Description:

The gravitational force of this Gravity Well.

Defaults to 50.

Source: src/gameobjects/particles/GravityWell.js#L175
Since: 3.0.0


power

power: number

Description:

The strength of the gravity force - larger numbers produce a stronger force.

Defaults to 0.

Source: src/gameobjects/particles/GravityWell.js#L152
Since: 3.0.0


Inherited Methods

From Phaser.GameObjects.Particles.ParticleProcessor:


Public Methods

update

<instance> update(particle, delta, step)

Description:

Takes a Particle and updates it based on the properties of this Gravity Well.

Parameters:

nametypeoptionaldescription
particlePhaser.GameObjects.Particles.ParticleNoThe Particle to update.
deltanumberNoThe delta time in ms.
stepnumberNoThe delta value divided by 1000.

Overrides: Phaser.GameObjects.Particles.ParticleProcessor#update

Source: src/gameobjects/particles/GravityWell.js#L95
Since: 3.0.0