Phaser API Documentation

  Version: 
Filter

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:

name type arguments Default description
x number | Phaser.Types.GameObjects.Particles.GravityWellConfig <optional> 0

The x coordinate of the Gravity Well, in world space.

y number <optional> 0

The y coordinate of the Gravity Well, in world space.

power number <optional> 0

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

epsilon number <optional> 100

The minimum distance for which the gravity force is calculated.

gravity number <optional> 50

The gravitational force of this Gravity Well.

Since: 3.0.0

Extends


Members

<private> _epsilon: number
Focus
Focus

Description:

Internal epsilon value.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
<private> _gravity: number
Focus
Focus

Description:

Internal gravity value.

Type:
number
Since: 3.0.0
Focus
Focus
<private> _power: number
Focus
Focus

Description:

Internal power value.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
active: boolean
Focus
Focus

Description:

The active state of the Particle Processor.

An inactive Particle Processor will be skipped for processing by its parent Emitter.

Type:
boolean
Inherited from: Phaser.GameObjects.Particles.ParticleProcessor#active
Since: 3.60.0
Focus
Focus
epsilon: number
Focus
Focus

Description:

The minimum distance for which the gravity force is calculated.

Defaults to 100.

Type:
number
Since: 3.0.0
Focus
Focus
gravity: number
Focus
Focus

Description:

The gravitational force of this Gravity Well.

Defaults to 50.

Type:
number
Since: 3.0.0
Focus
Focus

Description:

A reference to the Particle Emitter that owns this Processor. This is set automatically when the Processor is added to an Emitter and nulled when removed or destroyed.

Type:
Inherited from: Phaser.GameObjects.Particles.ParticleProcessor#manager
Since: 3.60.0
Focus
Focus
power: number
Focus
Focus

Description:

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

Defaults to 0.

Type:
number
Since: 3.0.0
Focus
Focus
x: number
Focus
Focus

Description:

The x coordinate of the Particle Processor, in world space.

Type:
number
Inherited from: Phaser.GameObjects.Particles.ParticleProcessor#x
Since: 3.60.0
Focus
Focus
y: number
Focus
Focus

Description:

The y coordinate of the Particle Processor, in world space.

Type:
number
Inherited from: Phaser.GameObjects.Particles.ParticleProcessor#y
Since: 3.60.0
Focus
Focus

Methods

destroy()
Focus
Focus

Description:

Destroys this Particle Processor by removing all external references.

This is called automatically when the owning Particle Emitter is destroyed.

Inherited from: Phaser.GameObjects.Particles.ParticleProcessor#destroy
Since: 3.60.0
Focus
Focus
update(particle, delta, step)
Focus
Focus

Description:

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

Parameters:

name type description
particle Phaser.GameObjects.Particles.Particle

The Particle to update.

delta number

The delta time in ms.

step number

The delta value divided by 1000.

Overrides: Phaser.GameObjects.Particles.ParticleProcessor#update
Since: 3.0.0
Focus
Focus