Skip to main content
Version: Phaser v4.0.0

Particle

A Particle is a lightweight object owned and controlled by a ParticleEmitter. Each Particle holds its own position, velocity, acceleration, rotation, scale, alpha, tint, and lifespan values, which are updated each frame by the Emitter's configured EmitterOp instances. Particles are pooled and recycled by the Emitter for performance. When a particle's lifespan expires, it is deactivated and returned to the pool for reuse rather than being destroyed. You do not normally create Particle instances directly; instead, the Emitter manages their lifecycle. You can extend this class to add custom properties by providing a custom particleClass in the emitter configuration.

Constructor

new Particle(emitter)

Parameters

nametypeoptionaldescription
emitterPhaser.GameObjects.Particles.ParticleEmitterNoThe Emitter to which this Particle belongs.

Scope: static

Source: src/gameobjects/particles/Particle.js#L15
Since: 3.0.0

Public Members

accelerationX

accelerationX: number

Description:

The x acceleration of this Particle, in pixels per second squared.

Source: src/gameobjects/particles/Particle.js#L121
Since: 3.0.0


accelerationY

accelerationY: number

Description:

The y acceleration of this Particle, in pixels per second squared.

Source: src/gameobjects/particles/Particle.js#L131
Since: 3.0.0


alpha

alpha: number

Description:

The alpha value of this Particle.

Source: src/gameobjects/particles/Particle.js#L191
Since: 3.0.0


angle

angle: number

Description:

The angle of this Particle in degrees.

Source: src/gameobjects/particles/Particle.js#L201
Since: 3.0.0


anims

anims: Phaser.Animations.AnimationState

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.

It is created only if the Particle's Emitter has at least one Animation.

Source: src/gameobjects/particles/Particle.js#L333
Since: 3.60.0


bounce

bounce: number

Description:

The bounciness, or restitution, of this Particle.

Source: src/gameobjects/particles/Particle.js#L161
Since: 3.0.0


bounds

bounds: Phaser.Geom.Rectangle

Description:

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

Source: src/gameobjects/particles/Particle.js#L354
Since: 3.60.0


data

data: Phaser.Types.GameObjects.Particles.ParticleData

Description:

An object that stores the min/max interpolation values for each of this Particle's properties (such as alpha, tint, scaleX, rotate, etc.) as they are eased over the particle's lifetime. These values are populated and used by the EmitterOp instances on the parent Emitter.

Source: src/gameobjects/particles/Particle.js#L281
Since: 3.0.0


delayCurrent

delayCurrent: number

Description:

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

Source: src/gameobjects/particles/Particle.js#L251
Since: 3.0.0


emitter

emitter: Phaser.GameObjects.Particles.ParticleEmitter

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.

Source: src/gameobjects/particles/Particle.js#L39
Since: 3.0.0


frame

frame: Phaser.Textures.Frame

Description:

The texture frame used by this Particle when it renders.

Source: src/gameobjects/particles/Particle.js#L60
Since: 3.0.0


holdCurrent

holdCurrent: number

Description:

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

Source: src/gameobjects/particles/Particle.js#L261
Since: 3.60.0


life

life: number

Description:

The lifespan of this Particle in ms.

Source: src/gameobjects/particles/Particle.js#L231
Since: 3.0.0


lifeCurrent

lifeCurrent: number

Description:

The current life of this Particle in ms.

Source: src/gameobjects/particles/Particle.js#L241
Since: 3.0.0


lifeT

lifeT: number

Description:

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

Source: src/gameobjects/particles/Particle.js#L271
Since: 3.0.0


maxVelocityX

maxVelocityX: number

Description:

The maximum horizontal velocity this Particle can travel at, in pixels per second.

Source: src/gameobjects/particles/Particle.js#L141
Since: 3.0.0


maxVelocityY

maxVelocityY: number

Description:

The maximum vertical velocity this Particle can travel at, in pixels per second.

Source: src/gameobjects/particles/Particle.js#L151
Since: 3.0.0


rotation

rotation: number

Description:

The angle of this Particle in radians.

Source: src/gameobjects/particles/Particle.js#L211
Since: 3.0.0


scaleX

scaleX: number

Description:

The horizontal scale of this Particle.

Source: src/gameobjects/particles/Particle.js#L171
Since: 3.0.0


scaleY

scaleY: number

Description:

The vertical scale of this Particle.

Source: src/gameobjects/particles/Particle.js#L181
Since: 3.0.0


scene

scene: Phaser.Scene

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.

Source: src/gameobjects/particles/Particle.js#L319
Since: 3.60.0


texture

texture: Phaser.Textures.Texture

Description:

The texture used by this Particle when it renders.

Source: src/gameobjects/particles/Particle.js#L50
Since: 3.60.0


tint

tint: number

Description:

The tint applied to this Particle.

Tags:

  • webglOnly

Source: src/gameobjects/particles/Particle.js#L221
Since: 3.0.0


velocityX

velocityX: number

Description:

The x velocity of this Particle, in pixels per second.

Source: src/gameobjects/particles/Particle.js#L101
Since: 3.0.0


velocityY

velocityY: number

Description:

The y velocity of this Particle, in pixels per second.

Source: src/gameobjects/particles/Particle.js#L111
Since: 3.0.0


worldPosition

worldPosition: Phaser.Math.Vector2

Description:

The coordinates of this Particle in world space.

Updated as part of computeVelocity.

Source: src/gameobjects/particles/Particle.js#L90
Since: 3.60.0


x

x: number

Description:

The x coordinate of this Particle.

Source: src/gameobjects/particles/Particle.js#L70
Since: 3.0.0


y

y: number

Description:

The y coordinate of this Particle.

Source: src/gameobjects/particles/Particle.js#L80
Since: 3.0.0


Public Methods

computeVelocity

<instance> computeVelocity(emitter, delta, step, processors, t)

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:

nametypeoptionaldescription
emitterPhaser.GameObjects.Particles.ParticleEmitterNoThe Emitter that is updating this Particle.
deltanumberNoThe delta time in ms.
stepnumberNoThe delta value divided by 1000.
processorsArray.<Phaser.GameObjects.Particles.ParticleProcessor>NoAn array of all active Particle Processors.
tnumberNoThe current normalized lifetime of the particle, between 0 (birth) and 1 (death).

Source: src/gameobjects/particles/Particle.js#L675
Since: 3.0.0


destroy

<instance> destroy()

Description:

Destroys this Particle by nulling its references to the emitter, texture, frame, and scene. If this Particle has an AnimationState, it is also destroyed. After calling this method the Particle should not be used again.

Source: src/gameobjects/particles/Particle.js#L796
Since: 3.60.0


emit

<instance> emit(event, [a1], [a2], [a3], [a4], [a5])

Description:

The Event Emitter proxy.

Passes on all parameters to the ParticleEmitter to emit directly.

Parameters:

nametypeoptionaldescription
eventstring | SymbolNoThe event name.
a1anyYesOptional argument 1.
a2anyYesOptional argument 2.
a3anyYesOptional argument 3.
a4anyYesOptional argument 4.
a5anyYesOptional argument 5.

Returns: boolean - true if the event had listeners, else false.

Source: src/gameobjects/particles/Particle.js#L365
Since: 3.60.0


fire

<instance> fire([x], [y])

Description:

Starts this Particle from the given coordinates.

Parameters:

nametypeoptionaldescription
xnumberYesThe x coordinate to launch this Particle from.
ynumberYesThe y coordinate to launch this Particle from.

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

Source: src/gameobjects/particles/Particle.js#L432
Since: 3.0.0


getBounds

<instance> getBounds([matrix])

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:

nametypeoptionaldescription
matrixPhaser.GameObjects.Components.TransformMatrixYesOptional transform matrix to apply to this particle.

Returns: Phaser.Geom.Rectangle - A Rectangle containing the transformed bounds of this particle.

Source: src/gameobjects/particles/Particle.js#L742
Since: 3.60.0


isAlive

<instance> isAlive()

Description:

Checks to see if this Particle is alive and updating.

Returns: boolean - true if this Particle is alive and updating, otherwise false.

Source: src/gameobjects/particles/Particle.js#L387
Since: 3.0.0


kill

<instance> kill()

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.

Source: src/gameobjects/particles/Particle.js#L400
Since: 3.60.0


setPosition

<instance> setPosition([x], [y])

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 (0, 0).

Parameters:

nametypeoptionaldefaultdescription
xnumberYes0The x coordinate to set this Particle to.
ynumberYes0The y coordinate to set this Particle to.

Source: src/gameobjects/particles/Particle.js#L412
Since: 3.60.0


setSizeToFrame

<instance> setSizeToFrame()

Description:

This is a NOOP method and does nothing when called.

Source: src/gameobjects/particles/Particle.js#L731
Since: 3.60.0


update

<instance> update(delta, step, processors)

Description:

The main update method for this Particle.

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

Parameters:

nametypeoptionaldescription
deltanumberNoThe delta time in ms.
stepnumberNoThe delta value divided by 1000.
processorsArray.<Phaser.GameObjects.Particles.ParticleProcessor>NoAn array of all active Particle Processors.

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

Source: src/gameobjects/particles/Particle.js#L570
Since: 3.0.0