Phaser API Documentation

  Version: 
Filter

A Particle is a simple object owned and controlled by a Particle Emitter.

It encapsulates all of the properties required to move and update according to the Emitters operations.

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

Description:

The Animation State component of this Particle.

This component provides features to apply animations to this Particle. It is responsible for playing, loading, queuing animations for later playback, mixing between animations and setting the current animation frame to this Particle.

Type:
Since: 3.60.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

Description:

A rectangle that holds the bounds of this Particle after a call to the Particle.getBounds method has been made.

Type:
Since: 3.60.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 by it.

Type:
Since: 3.0.0
Focus
Focus

Description:

The texture frame used by this Particle when it renders.

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

Description:

The hold applied to this Particle before it expires, in ms.

Type:
number
Default: 0
Since: 3.60.0
Focus
Focus
<private, readonly> isCropped: boolean
Focus
Focus

Description:

Interal private value.

Type:
boolean
Since: 3.60.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
scene: Phaser.Scene
Focus
Focus

Description:

A reference to the Scene to which this Game Object belongs.

Game Objects can only belong to one Scene.

You should consider this property as being read-only. You cannot move a Game Object to another Scene by simply changing it.

Type:
Since: 3.60.0
Focus
Focus

Description:

The texture used by this Particle when it renders.

Type:
Default: null
Since: 3.60.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
worldPosition: Phaser.Math.Vector2
Focus
Focus

Description:

The coordinates of this Particle in world space.

Updated as part of computeVelocity.

Type:
Since: 3.60.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

computeVelocity(emitter, delta, step, processors, t)
Focus
Focus

Description:

An internal method that calculates the velocity of the Particle and its world position. It also runs it against any active Processors that are set on the Emitter.

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.<Phaser.GameObjects.Particles.ParticleProcessor>

An array of all active Particle Processors.

t number

The current normalized lifetime of the particle, between 0 (birth) and 1 (death).

Since: 3.0.0
Focus
Focus
destroy()
Focus
Focus

Description:

Destroys this Particle.

Since: 3.60.0
Focus
Focus
emit(event, [a1], [a2], [a3], [a4], [a5])
Focus
Focus

Description:

The Event Emitter proxy.

Passes on all parameters to the ParticleEmitter to emit directly.

Parameters:

name type arguments description
event string | Symbol

The event name.

a1 any <optional>

Optional argument 1.

a2 any <optional>

Optional argument 2.

a3 any <optional>

Optional argument 3.

a4 any <optional>

Optional argument 4.

a5 any <optional>

Optional argument 5.

Returns:
Description:

true if the event had listeners, else false.

Type:
  • boolean
Since: 3.60.0
Focus
Focus
fire([x], [y])
Focus
Focus

Description:

Starts this Particle from the given coordinates.

Parameters:

name type arguments description
x number <optional>

The x coordinate to launch this Particle from.

y number <optional>

The y coordinate to launch this Particle from.

Returns:
Description:

true if the Particle is alive, or false if it was spawned inside a DeathZone.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
getBounds([matrix])
Focus
Focus

Description:

Gets the bounds of this particle as a Geometry Rectangle, factoring in any transforms of the parent emitter and anything else above it in the display list.

Once calculated the bounds can be accessed via the Particle.bounds property.

Parameters:

name type arguments description
matrix Phaser.GameObjects.Components.TransformMatrix <optional>

Optional transform matrix to apply to this particle.

Returns:
Description:

A Rectangle containing the transformed bounds of this particle.

Since: 3.60.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
kill()
Focus
Focus

Description:

Kills this particle. This sets the lifeCurrent value to 0, which forces the Particle to be removed the next time its parent Emitter runs an update.

Since: 3.60.0
Focus
Focus
setPosition([x], [y])
Focus
Focus

Description:

Sets the position of this particle to the given x/y coordinates.

If the parameters are left undefined, it resets the particle back to 0x0.

Parameters:

name type arguments description
x number <optional>

The x coordinate to set this Particle to.

y number <optional>

The y coordinate to set this Particle to.

Since: 3.60.0
Focus
Focus
setSizeToFrame()
Focus
Focus

Description:

This is a NOOP method and does nothing when called.

Since: 3.60.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.<Phaser.GameObjects.Particles.ParticleProcessor>

An array of all active Particle 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