Phaser API Documentation

  Version: 
Filter

A Particle is a simple Game Object controlled by a Particle Emitter and Manager, and rendered by the Manager. It uses its own lightweight physics system, and can interact only with its Emitter's bounds and zones.

Constructor:

new Particle(emitter)

Parameters:

name type description
emitter Phaser.GameObjects.Particles.ParticleEmitter

The Emitter to which this Particle belongs.

Since: 3.0.0

Members

accelerationX: number
Focus
Focus

Description:

The x acceleration of this Particle.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
accelerationY: number
Focus
Focus

Description:

The y acceleration of this Particle.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
alpha: number
Focus
Focus

Description:

The alpha value of this Particle.

Type:
number
Default: 1
Since: 3.0.0
Focus
Focus
angle: number
Focus
Focus

Description:

The angle of this Particle in degrees.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
bounce: number
Focus
Focus

Description:

The bounciness, or restitution, of this Particle.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
data: object
Focus
Focus

Description:

The data used by the ease equation.

Type:
object
Since: 3.0.0
Focus
Focus
delayCurrent: number
Focus
Focus

Description:

The delay applied to this Particle upon emission, in ms.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus

Description:

The Emitter to which this Particle belongs.

A Particle can only belong to a single Emitter and is created, updated and destroyed via it.

Type:
Since: 3.0.0
Focus
Focus

Description:

The texture frame used to render this Particle.

Type:
Default: null
Since: 3.0.0
Focus
Focus
life: number
Focus
Focus

Description:

The lifespan of this Particle in ms.

Type:
number
Default: 1000
Since: 3.0.0
Focus
Focus
lifeCurrent: number
Focus
Focus

Description:

The current life of this Particle in ms.

Type:
number
Default: 1000
Since: 3.0.0
Focus
Focus
lifeT: number
Focus
Focus

Description:

The normalized lifespan T value, where 0 is the start and 1 is the end.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
maxVelocityX: number
Focus
Focus

Description:

The maximum horizontal velocity this Particle can travel at.

Type:
number
Default: 10000
Since: 3.0.0
Focus
Focus
maxVelocityY: number
Focus
Focus

Description:

The maximum vertical velocity this Particle can travel at.

Type:
number
Default: 10000
Since: 3.0.0
Focus
Focus
rotation: number
Focus
Focus

Description:

The angle of this Particle in radians.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
scaleX: number
Focus
Focus

Description:

The horizontal scale of this Particle.

Type:
number
Default: 1
Since: 3.0.0
Focus
Focus
scaleY: number
Focus
Focus

Description:

The vertical scale of this Particle.

Type:
number
Default: 1
Since: 3.0.0
Focus
Focus
Only webGL tint: number
Focus
Focus

Description:

The tint applied to this Particle.

Type:
number
Since: 3.0.0
Focus
Focus
velocityX: number
Focus
Focus

Description:

The x velocity of this Particle.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
velocityY: number
Focus
Focus

Description:

The y velocity of this Particle.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
x: number
Focus
Focus

Description:

The x coordinate of this Particle.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
y: number
Focus
Focus

Description:

The y coordinate of this Particle.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus

Methods

checkBounds(emitter)
Focus
Focus

Description:

Checks if this Particle is still within the bounds defined by the given Emitter.

If not, and depending on the Emitter collision flags, the Particle may either stop or rebound.

Parameters:

name type description
emitter Phaser.GameObjects.Particles.ParticleEmitter

The Emitter to check the bounds against.

Since: 3.0.0
Focus
Focus
computeVelocity(emitter, delta, step, processors)
Focus
Focus

Description:

An internal method that calculates the velocity of the Particle.

Parameters:

name type description
emitter Phaser.GameObjects.Particles.ParticleEmitter

The Emitter that is updating this Particle.

delta number

The delta time in ms.

step number

The delta value divided by 1000.

processors array

Particle processors (gravity wells).

Since: 3.0.0
Focus
Focus
fire(x, y)
Focus
Focus

Description:

Starts this Particle from the given coordinates.

Parameters:

name type description
x number

The x coordinate to launch this Particle from.

y number

The y coordinate to launch this Particle from.

Since: 3.0.0
Focus
Focus
isAlive()
Focus
Focus

Description:

Checks to see if this Particle is alive and updating.

Returns:
Description:

true if this Particle is alive and updating, otherwise false.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
resetPosition()
Focus
Focus

Description:

Resets the position of this particle back to zero.

Since: 3.16.0
Focus
Focus
update(delta, step, processors)
Focus
Focus

Description:

The main update method for this Particle.

Updates its life values, computes the velocity and repositions the Particle.

Parameters:

name type description
delta number

The delta time in ms.

step number

The delta value divided by 1000.

processors array

An optional array of update processors.

Returns:
Description:

Returns true if this Particle has now expired and should be removed, otherwise false if still active.

Type:
  • boolean
Since: 3.0.0
Focus
Focus