Class: ParticleEmitter

Phaser.GameObjects.Particles. ParticleEmitter

A particle emitter represents a single particle stream.
It controls a pool of Particles and is controlled by a Particle Emitter Manager.


new ParticleEmitter(manager, config)

Parameters:
Name Type Description
manager Phaser.GameObjects.Particles.ParticleEmitterManager

The Emitter Manager this Emitter belongs to.

config ParticleEmitterConfig

Settings for this emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 149)

Extends

Members


acceleration :boolean

Whether accelerationX and accelerationY are non-zero. Set automatically during configuration.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/gameobjects/particles/ParticleEmitter.js (Line 358)

accelerationX :Phaser.GameObjects.Particles.EmitterOp

Horizontal acceleration applied to emitted particles, in pixels per second squared.

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 368)

accelerationY :Phaser.GameObjects.Particles.EmitterOp

Vertical acceleration applied to emitted particles, in pixels per second squared.

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 378)

active :boolean

Whether this emitter updates itself and its particles.

Controlled by Phaser.GameObjects.Particles.ParticleEmitter#pause
and Phaser.GameObjects.Particles.ParticleEmitter#resume.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 741)

alpha :Phaser.GameObjects.Particles.EmitterOp

The alpha (transparency) of emitted particles.

Type:
Since: 3.0.0
Default Value:
  • 1
Source: src/gameobjects/particles/ParticleEmitter.js (Line 504)
See:

angle :Phaser.GameObjects.Particles.EmitterOp

The angle of the initial velocity of emitted particles, in degrees.

Type:
Since: 3.0.0
Default Value:
  • { min: 0, max: 360 }
Source: src/gameobjects/particles/ParticleEmitter.js (Line 526)
See:

blendMode :integer

The blend mode of this emitter's particles.

Type:
  • integer
Since: 3.0.0
Overrides:
Source: src/gameobjects/particles/ParticleEmitter.js (Line 765)
See:

bounce :Phaser.GameObjects.Particles.EmitterOp

Whether particles will rebound when they meet the emitter bounds.

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 460)

<nullable> bounds :Phaser.Geom.Rectangle

A rectangular boundary constraining particle movement.

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/gameobjects/particles/ParticleEmitter.js (Line 690)
See:

collideBottom :boolean

Whether particles interact with the bottom edge of the emitter Phaser.GameObjects.Particles.ParticleEmitter#bounds.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 731)

collideLeft :boolean

Whether particles interact with the left edge of the emitter Phaser.GameObjects.Particles.ParticleEmitter#bounds.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 701)

collideRight :boolean

Whether particles interact with the right edge of the emitter Phaser.GameObjects.Particles.ParticleEmitter#bounds.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 711)

collideTop :boolean

Whether particles interact with the top edge of the emitter Phaser.GameObjects.Particles.ParticleEmitter#bounds.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 721)

configFastMap :object

Names of simple configuration properties.

Type:
  • object
Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 216)

configOpMap :object

Names of complex configuration properties.

Type:
  • object
Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 249)

currentFrame :integer

The current texture frame, as an index of Phaser.GameObjects.Particles.ParticleEmitter#frames.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 809)
See:

<nullable> deathCallback :ParticleDeathCallback

A function to call when a particle dies.

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/gameobjects/particles/ParticleEmitter.js (Line 567)

<nullable> deathCallbackScope :*

Type:
  • *
Since: 3.0.0
Default Value:
  • null
Source: src/gameobjects/particles/ParticleEmitter.js (Line 577)

<nullable> deathZone :Phaser.GameObjects.Particles.Zones.DeathZone

An object describing a shape that deactivates particles when they interact with it.

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/gameobjects/particles/ParticleEmitter.js (Line 679)
See:

defaultFrame :Phaser.Textures.Frame

The default texture frame assigned to particles.

Type:
Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 207)

delay :Phaser.GameObjects.Particles.EmitterOp

How many ms to wait after emission before the particles start updating.

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 610)

<nullable> emitCallback :ParticleEmitterCallback

A function to call when a particle is emitted.

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/gameobjects/particles/ParticleEmitter.js (Line 547)

<nullable> emitCallbackScope :*

Type:
  • *
Since: 3.0.0
Default Value:
  • null
Source: src/gameobjects/particles/ParticleEmitter.js (Line 557)

emitZone :Phaser.GameObjects.Particles.Zones.EdgeZone|Phaser.GameObjects.Particles.Zones.RandomZone

An object describing a shape to emit particles from.

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/gameobjects/particles/ParticleEmitter.js (Line 668)
See:

<nullable> follow :Phaser.GameObjects.GameObject

A Game Object whose position is used as the particle origin.

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/gameobjects/particles/ParticleEmitter.js (Line 775)
See:

followOffset :Phaser.Math.Vector2

The offset of the particle origin from the Phaser.GameObjects.Particles.ParticleEmitter#follow target.

Type:
Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 787)
See:

frameQuantity :integer

The number of consecutive particles that receive a single texture frame (per frame cycle).

Type:
  • integer
Since: 3.0.0
Default Value:
  • 1
Source: src/gameobjects/particles/ParticleEmitter.js (Line 831)
See:

frames :Array.<Phaser.Textures.Frame>

The texture frames assigned to particles.

Type:
Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 198)

frequency :number

For a flow emitter, the time interval (>= 0) between particle flow cycles in ms.
A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting.
For an exploding emitter, this value will be -1.
Calling Phaser.GameObjects.Particles.ParticleEmitter#flow also puts the emitter in flow mode (frequency >= 0).
Calling Phaser.GameObjects.Particles.ParticleEmitter#explode also puts the emitter in explode mode (frequency = -1).

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 620)
See:

gravityX :number

Horizontal acceleration applied to emitted particles, in pixels per second squared.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 336)
See:

gravityY :number

Vertical acceleration applied to emitted particles, in pixels per second squared.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 347)
See:

lifespan :Phaser.GameObjects.Particles.EmitterOp

The lifespan of emitted particles, in ms.

Type:
Since: 3.0.0
Default Value:
  • 1000
Source: src/gameobjects/particles/ParticleEmitter.js (Line 515)
See:

manager :Phaser.GameObjects.Particles.ParticleEmitterManager

The Emitter Manager this Emitter belongs to.

Type:
Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 180)

mask :Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask

The Mask this Game Object is using during render.

Type:
Since: 3.0.0
Inherited From:
Source: src/gameobjects/components/Mask.js (Line 19)

maxParticles :integer

Set to hard limit the amount of particle objects this emitter is allowed to create.
0 means unlimited.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 587)

maxVelocityX :Phaser.GameObjects.Particles.EmitterOp

The maximum horizontal velocity of emitted particles, in pixels per second squared.

Type:
Since: 3.0.0
Default Value:
  • 10000
Source: src/gameobjects/particles/ParticleEmitter.js (Line 388)

maxVelocityY :Phaser.GameObjects.Particles.EmitterOp

The maximum vertical velocity of emitted particles, in pixels per second squared.

Type:
Since: 3.0.0
Default Value:
  • 10000
Source: src/gameobjects/particles/ParticleEmitter.js (Line 398)

moveTo :boolean

Whether moveToX and moveToY are nonzero. Set automatically during configuration.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/gameobjects/particles/ParticleEmitter.js (Line 430)

moveToX :Phaser.GameObjects.Particles.EmitterOp

The x-coordinate emitted particles move toward, when Phaser.GameObjects.Particles.ParticleEmitter#moveTo is true.

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 440)

moveToY :Phaser.GameObjects.Particles.EmitterOp

The y-coordinate emitted particles move toward, when Phaser.GameObjects.Particles.ParticleEmitter#moveTo is true.

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 450)

name :string

The name of this Particle Emitter.

Empty by default and never populated by Phaser, this is left for developers to use.

Type:
  • string
Since: 3.0.0
Default Value:
  • ''
Source: src/gameobjects/particles/ParticleEmitter.js (Line 279)

on :boolean

Controls if the emitter is currently emitting a particle flow (when frequency >= 0).
Already alive particles will continue to update until they expire.
Controlled by Phaser.GameObjects.Particles.ParticleEmitter#start and Phaser.GameObjects.Particles.ParticleEmitter#stop.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 635)

particleBringToTop :boolean

Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive.
Set to false to send them to the back.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 647)

particleClass :Phaser.GameObjects.Particles.Particle

The Particle Class which will be emitted by this Emitter.

Type:
Since: 3.0.0
Default Value:
  • Phaser.GameObjects.Particles.Particle
Source: src/gameobjects/particles/ParticleEmitter.js (Line 291)

quantity :Phaser.GameObjects.Particles.EmitterOp

How many particles are emitted each time particles are emitted (one explosion or one flow cycle).

Type:
Since: 3.0.0
Default Value:
  • 1
Source: src/gameobjects/particles/ParticleEmitter.js (Line 598)
See:

radial :boolean

A radial emitter will emit particles in all directions between angle min and max,
using Phaser.GameObjects.Particles.ParticleEmitter#speed as the value. If set to false then this acts as a point Emitter.
A point emitter will emit particles only in the direction derived from the speedX and speedY values.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 323)
See:

randomFrame :boolean

Whether texture Phaser.GameObjects.Particles.ParticleEmitter#frames are selected at random.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 820)
See:

rotate :Phaser.GameObjects.Particles.EmitterOp

The rotation of emitted particles, in degrees.

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 537)

scaleX :Phaser.GameObjects.Particles.EmitterOp

The horizontal scale of emitted particles.

Type:
Since: 3.0.0
Default Value:
  • 1
Source: src/gameobjects/particles/ParticleEmitter.js (Line 470)
See:

scaleY :Phaser.GameObjects.Particles.EmitterOp

The vertical scale of emitted particles.

Type:
Since: 3.0.0
Default Value:
  • 1
Source: src/gameobjects/particles/ParticleEmitter.js (Line 482)
See:

scrollFactorX :number

The horizontal scroll factor of this Game Object.

The scroll factor controls the influence of the movement of a Camera upon this Game Object.

When a camera scrolls it will change the location at which this Game Object is rendered on-screen.
It does not change the Game Objects actual position values.

A value of 1 means it will move exactly in sync with a camera.
A value of 0 means it will not move at all, even if the camera moves.
Other values control the degree to which the camera movement is mapped to this Game Object.

Please be aware that scroll factor values other than 1 are not taken in to consideration when
calculating physics collisions. Bodies always collide based on their world position, but changing
the scroll factor is a visual adjustment to where the textures are rendered, which can offset
them from physics bodies if not accounted for in your code.

Type:
  • number
Since: 3.0.0
Inherited From:
Default Value:
  • 1
Source: src/gameobjects/components/ScrollFactor.js (Line 16)

scrollFactorY :number

The vertical scroll factor of this Game Object.

The scroll factor controls the influence of the movement of a Camera upon this Game Object.

When a camera scrolls it will change the location at which this Game Object is rendered on-screen.
It does not change the Game Objects actual position values.

A value of 1 means it will move exactly in sync with a camera.
A value of 0 means it will not move at all, even if the camera moves.
Other values control the degree to which the camera movement is mapped to this Game Object.

Please be aware that scroll factor values other than 1 are not taken in to consideration when
calculating physics collisions. Bodies always collide based on their world position, but changing
the scroll factor is a visual adjustment to where the textures are rendered, which can offset
them from physics bodies if not accounted for in your code.

Type:
  • number
Since: 3.0.0
Inherited From:
Default Value:
  • 1
Source: src/gameobjects/components/ScrollFactor.js (Line 40)

speedX :Phaser.GameObjects.Particles.EmitterOp

The initial horizontal speed of emitted particles, in pixels per second.

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 408)
See:

speedY :Phaser.GameObjects.Particles.EmitterOp

The initial vertical speed of emitted particles, in pixels per second.

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 419)
See:

texture :Phaser.Textures.Texture

The texture assigned to particles.

Type:
Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 189)

timeScale :number

The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal.

Type:
  • number
Since: 3.0.0
Default Value:
  • 1
Source: src/gameobjects/particles/ParticleEmitter.js (Line 658)

tint :Phaser.GameObjects.Particles.EmitterOp

Color tint applied to emitted particles. Any alpha component (0xAA000000) is ignored.

Type:
Since: 3.0.0
Default Value:
  • 0xffffffff
Source: src/gameobjects/particles/ParticleEmitter.js (Line 494)

trackVisible :boolean

Whether the emitter's Phaser.GameObjects.Particles.ParticleEmitter#visible state will track
the Phaser.GameObjects.Particles.ParticleEmitter#follow target's visibility state.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/gameobjects/particles/ParticleEmitter.js (Line 797)
See:

visible :boolean

Set this to false to hide any active particles.

Type:
  • boolean
Since: 3.0.0
Overrides:
Default Value:
  • true
Source: src/gameobjects/particles/ParticleEmitter.js (Line 754)
See:

x :Phaser.GameObjects.Particles.EmitterOp

The x-coordinate of the particle origin (where particles will be emitted).

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 301)
See:

y :Phaser.GameObjects.Particles.EmitterOp

The y-coordinate of the particle origin (where particles will be emitted).

Type:
Since: 3.0.0
Default Value:
  • 0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 312)
See:

Methods


atLimit()

Whether this emitter is at its limit (if set).

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1695)
Returns:

Returns true if this Emitter is at its limit, or false if no limit, or below the maxParticles level.

Type
boolean

clearMask( [destroyMask])

Clears the mask that this Game Object was using.

Parameters:
Name Type Argument Default Description
destroyMask boolean <optional>
false

Destroy the mask before clearing it?

Since: 3.6.2
Inherited From:
Source: src/gameobjects/components/Mask.js (Line 56)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Particles.ParticleEmitter

createBitmapMask( [renderable])

Creates and returns a Bitmap Mask. This mask can be used by any Game Object,
including this one.

To create the mask you need to pass in a reference to a renderable Game Object.
A renderable Game Object is one that uses a texture to render with, such as an
Image, Sprite, Render Texture or BitmapText.

If you do not provide a renderable object, and this Game Object has a texture,
it will use itself as the object. This means you can call this method to create
a Bitmap Mask from any renderable Game Object.

Parameters:
Name Type Argument Description
renderable Phaser.GameObjects.GameObject <optional>

A renderable Game Object that uses a texture, such as a Sprite.

Since: 3.6.2
Inherited From:
Source: src/gameobjects/components/Mask.js (Line 80)
Returns:

This Bitmap Mask that was created.

Type
Phaser.Display.Masks.BitmapMask

createGeometryMask( [graphics])

Creates and returns a Geometry Mask. This mask can be used by any Game Object,
including this one.

To create the mask you need to pass in a reference to a Graphics Game Object.

If you do not provide a graphics object, and this Game Object is an instance
of a Graphics object, then it will use itself to create the mask.

This means you can call this method to create a Geometry Mask from any Graphics Game Object.

Parameters:
Name Type Argument Description
graphics Phaser.GameObjects.Graphics <optional>

A Graphics Game Object. The geometry within it will be used as the mask.

Since: 3.6.2
Inherited From:
Source: src/gameobjects/components/Mask.js (Line 110)
Returns:

This Geometry Mask that was created.

Type
Phaser.Display.Masks.GeometryMask

depthSort()

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1910)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

depthSortCallback(a, b)

Calculates the difference of two particles, for sorting them by depth.

Parameters:
Name Type Description
a object

The first particle.

b object

The second particle.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 2142)
Returns:

The difference of a and b's y coordinates.

Type
integer

emitParticle( [count] [, x] [, y])

Emits particles at a given position (or the emitter's current position).

Parameters:
Name Type Argument Default Description
count integer <optional>
this.quantity

The number of Particles to emit.

x number <optional>
this.x

The x coordinate to emit the Particles from.

y number <optional>
this.x

The y coordinate to emit the Particles from.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1985)
See:
Returns:

The most recently emitted Particle.

Type
Phaser.GameObjects.Particles.Particle

emitParticleAt( [x] [, y] [, count])

Emits particles at a given position (or the emitter's current position).

Parameters:
Name Type Argument Default Description
x number <optional>
this.x

The x coordinate to emit the Particles from.

y number <optional>
this.x

The y coordinate to emit the Particles from.

count integer <optional>
this.quantity

The number of Particles to emit.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1968)
Returns:

The most recently emitted Particle.

Type
Phaser.GameObjects.Particles.Particle

explode(count, x, y)

Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once.

Parameters:
Name Type Description
count integer

The amount of Particles to emit.

x number

The x coordinate to emit the Particles from.

y number

The y coordinate to emit the Particles from.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1949)
Returns:

The most recently emitted Particle.

Type
Phaser.GameObjects.Particles.Particle

flow(frequency [, count])

Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow.

To resume a flow at the current frequency and quantity, use Phaser.GameObjects.Particles.ParticleEmitter#start instead.

Parameters:
Name Type Argument Default Description
frequency number

The time interval (>= 0) of each flow cycle, in ms.

count number | Array.<float> | EmitterOpOnEmitCallback | object <optional>
1

The number of particles to emit at each flow cycle.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1925)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

forEachAlive(callback, context)

Calls a function for each active particle in this emitter.

Parameters:
Name Type Description
callback ParticleEmitterCallback

The function.

context *

The function's calling context.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1793)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

forEachDead(callback, context)

Calls a function for each inactive particle in this emitter.

Parameters:
Name Type Description
callback ParticleEmitterCallback

The function.

context *

The function's calling context.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1818)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

fromJSON(config)

Merges configuration settings into the emitter's current settings.

Parameters:
Name Type Description
config ParticleEmitterConfig

Settings for this emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 890)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

getAliveParticleCount()

Gets the number of active (in-use) particles in this emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1656)
Returns:

The number of particles with active=true.

Type
integer

getDeadParticleCount()

Gets the number of inactive (available) particles in this emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1669)
Returns:

The number of particles with active=false.

Type
integer

getFrame()

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1087)
Returns:

The texture frame.

Type
Phaser.Textures.Frame

getParticleCount()

Gets the total number of particles in this emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1682)
Returns:

The number of particles, including both alive and dead.

Type
integer

indexSortCallback(a, b)

Calculates the difference of two particles, for sorting them by index.

Parameters:
Name Type Description
a object

The first particle.

b object

The second particle.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 2158)
Returns:

The difference of a and b's index properties.

Type
integer

killAll()

Deactivates every particle in this emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1772)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

onParticleDeath(callback [, context])

Sets a function to call for each particle death.

Parameters:
Name Type Argument Description
callback ParticleDeathCallback

The function.

context * <optional>

The function's calling context.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1740)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

onParticleEmit(callback [, context])

Sets a function to call for each newly emitted particle.

Parameters:
Name Type Argument Description
callback ParticleEmitterCallback

The function.

context * <optional>

The calling context.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1708)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

pause()

Deactivates the emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1880)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

preUpdate(time, delta)

Updates this emitter and its particles.

Parameters:
Name Type Description
time integer

The current timestamp as generated by the Request Animation Frame or SetTimeout.

delta number

The delta time, in ms, elapsed since the last frame.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 2051)

reserve(particleCount)

Creates inactive particles and adds them to this emitter's pool.

Parameters:
Name Type Description
particleCount integer

The number of particles to create.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1634)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

resume()

Activates the emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1895)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setAlpha(value)

Sets the opacity of emitted particles.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnUpdateCallback | object

A value between 0 (transparent) and 1 (opaque).

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1434)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setAngle(value)

Sets the angle of a Phaser.GameObjects.Particles.ParticleEmitter#radial particle stream.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnEmitCallback | object

The angle of the initial velocity of emitted particles.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1468)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setBlendMode(value)

Sets the Blend Mode being used by this Game Object.

This can be a const, such as Phaser.BlendModes.SCREEN, or an integer, such as 4 (for Overlay)

Under WebGL only the following Blend Modes are available:

  • ADD
  • MULTIPLY
  • SCREEN

Canvas has more available depending on browser support.

You can also create your own custom Blend Modes in WebGL.

Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
reasons try to be careful about the construction of your Scene and the frequency of which blend modes
are used.

Parameters:
Name Type Description
value string | Phaser.BlendModes

The BlendMode value. Either a string or a CONST.

Since: 3.0.0
Inherited From:
Source: src/gameobjects/components/BlendMode.js (Line 78)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setBounds(x, y, width, height)

Sets or modifies a rectangular boundary constraining the particles.

To remove the boundary, set Phaser.GameObjects.Particles.ParticleEmitter#bounds to null.

Parameters:
Name Type Description
x number | ParticleEmitterBounds | ParticleEmitterBoundsAlt

The x-coordinate of the left edge of the boundary, or an object representing a rectangle.

y number

The y-coordinate of the top edge of the boundary.

width number

The width of the boundary.

height number

The height of the boundary.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1223)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setDeathZone( [zoneConfig])

Parameters:
Name Type Argument Description
zoneConfig ParticleEmitterDeathZoneConfig <optional>

An object describing the zone, or undefined to remove any current death zone.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1598)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setEmitterAngle(value)

Sets the angle of a Phaser.GameObjects.Particles.ParticleEmitter#radial particle stream.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnEmitCallback | object

The angle of the initial velocity of emitted particles.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1451)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setEmitZone( [zoneConfig])

Sets or removes the Phaser.GameObjects.Particles.ParticleEmitter#emitZone.

An EdgeZone places particles on its edges. Its source can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable getPoints method.

A RandomZone places randomly within its interior. Its source can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable getRandomPoint method.

Parameters:
Name Type Argument Description
zoneConfig ParticleEmitterEdgeZoneConfig | ParticleEmitterRandomZoneConfig <optional>

An object describing the zone, or undefined to remove any current emit zone.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1545)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setFrame(frames [, pickRandom] [, quantity])

Sets a pattern for assigning texture frames to emitted particles.

Parameters:
Name Type Argument Default Description
frames array | string | integer | ParticleEmitterFrameConfig

One or more texture frames, or a configuration object.

pickRandom boolean <optional>
true

Whether frames should be assigned at random from frames.

quantity integer <optional>
1

The number of consecutive particles that will receive each frame.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1127)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setFrequency(frequency [, quantity])

Parameters:
Name Type Argument Description
frequency number

The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode.

quantity number | Array.<float> | EmitterOpOnEmitCallback | object <optional>

The number of particles to release at each flow cycle or explosion.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1519)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setGravity(x, y)

Sets the gravity applied to emitted particles.

Parameters:
Name Type Description
x number

Horizontal acceleration due to gravity, in pixels per second squared.

y number

Vertical acceleration due to gravity, in pixels per second squared.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1415)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setGravityX(value)

Sets the horizontal gravity applied to emitted particles.

Parameters:
Name Type Description
value number

Acceleration due to gravity, in pixels per second squared.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1381)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setGravityY(value)

Sets the vertical gravity applied to emitted particles.

Parameters:
Name Type Description
value number

Acceleration due to gravity, in pixels per second squared.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1398)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setLifespan(value)

Sets the lifespan of newly emitted particles.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnEmitCallback | object

The particle lifespan, in ms.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1485)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setMask(mask)

Sets the mask that this Game Object will use to render with.

The mask must have been previously created and can be either a GeometryMask or a BitmapMask.
Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas.

If a mask is already set on this Game Object it will be immediately replaced.

Masks are positioned in global space and are not relative to the Game Object to which they
are applied. The reason for this is that multiple Game Objects can all share the same mask.

Masks have no impact on physics or input detection. They are purely a rendering component
that allows you to limit what is visible during the render pass.

Parameters:
Name Type Description
mask Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask

The mask this Game Object will use when rendering.

Since: 3.6.2
Inherited From:
Source: src/gameobjects/components/Mask.js (Line 28)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setPosition(x, y)

Sets the position of the emitter's particle origin.
New particles will be emitted here.

Parameters:
Name Type Description
x number | Array.<float> | EmitterOpOnEmitCallback | object

The x-coordinate of the particle origin.

y number | Array.<float> | EmitterOpOnEmitCallback | object

The y-coordinate of the particle origin.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1203)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setQuantity(quantity)

Sets the number of particles released at each flow cycle or explosion.

Parameters:
Name Type Description
quantity number | Array.<float> | EmitterOpOnEmitCallback | object

The number of particles to release at each flow cycle or explosion.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1502)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setRadial( [value])

Turns Phaser.GameObjects.Particles.ParticleEmitter#radial particle movement on or off.

Parameters:
Name Type Argument Default Description
value boolean <optional>
true

Radial mode (true) or point mode (true).

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1184)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setScale(value)

Sets the scale of emitted particles.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnUpdateCallback | object

The scale, relative to 1.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1363)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setScaleX(value)

Sets the horizontal scale of emitted particles.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnUpdateCallback | object

The scale, relative to 1.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1329)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setScaleY(value)

Sets the vertical scale of emitted particles.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnUpdateCallback | object

The scale, relative to 1.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1346)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setScrollFactor(x [, y])

Sets the scroll factor of this Game Object.

The scroll factor controls the influence of the movement of a Camera upon this Game Object.

When a camera scrolls it will change the location at which this Game Object is rendered on-screen.
It does not change the Game Objects actual position values.

A value of 1 means it will move exactly in sync with a camera.
A value of 0 means it will not move at all, even if the camera moves.
Other values control the degree to which the camera movement is mapped to this Game Object.

Please be aware that scroll factor values other than 1 are not taken in to consideration when
calculating physics collisions. Bodies always collide based on their world position, but changing
the scroll factor is a visual adjustment to where the textures are rendered, which can offset
them from physics bodies if not accounted for in your code.

Parameters:
Name Type Argument Default Description
x number

The horizontal scroll factor of this Game Object.

y number <optional>
x

The vertical scroll factor of this Game Object. If not set it will use the x value.

Since: 3.0.0
Inherited From:
Source: src/gameobjects/components/ScrollFactor.js (Line 64)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setSpeed(value)

Sets the initial radial speed of emitted particles.
Changes the emitter to radial mode.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnEmitCallback | object

The speed, in pixels per second.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1307)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setSpeedX(value)

Sets the initial horizontal speed of emitted particles.
Changes the emitter to point mode.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnEmitCallback | object

The speed, in pixels per second.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1262)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setSpeedY(value)

Sets the initial vertical speed of emitted particles.
Changes the emitter to point mode.

Parameters:
Name Type Description
value number | Array.<float> | EmitterOpOnEmitCallback | object

The speed, in pixels per second.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1283)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setVisible(value)

Sets the visibility of this Game Object.

An invisible Game Object will skip rendering, but will still process update logic.

Parameters:
Name Type Description
value boolean

The visible state of the Game Object.

Since: 3.0.0
Inherited From:
Source: src/gameobjects/components/Visible.js (Line 63)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Particles.ParticleEmitter

start()

Turns Phaser.GameObjects.Particles.ParticleEmitter#on the emitter and resets the flow counter.

If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart).

If this emitter is in explode mode (frequency = -1), nothing will happen.
Use Phaser.GameObjects.Particles.ParticleEmitter#explode or Phaser.GameObjects.Particles.ParticleEmitter#flow instead.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1843)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

startFollow(target [, offsetX] [, offsetY] [, trackVisible])

Continuously moves the particle origin to follow a Game Object's position.

Parameters:
Name Type Argument Default Description
target Phaser.GameObjects.GameObject

The Game Object to follow.

offsetX number <optional>
0

Horizontal offset of the particle origin from the Game Object.

offsetY number <optional>
0

Vertical offset of the particle origin from the Game Object.

trackVisible boolean <optional>
false

Whether the emitter's visible state will track the target's visible state.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1044)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

stop()

Turns off the emitter.

Since: 3.11.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1865)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

stopFollow()

Stops following a Game Object.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1070)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

toJSON( [output])

Creates a description of this emitter suitable for JSON serialization.

Parameters:
Name Type Argument Description
output object <optional>

An object to copy output into.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 994)
Returns:
  • The output object.
Type
object