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

Settings for this emitter.

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

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 233)

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 243)

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 253)

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 616)

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 379)
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 401)
See:

blendMode :number

The blend mode of this emitter's particles.

Type:
  • number
Since: 3.0.0
Overrides:
Source: src/gameobjects/particles/ParticleEmitter.js (Line 640)
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 335)

<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 565)
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 606)

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 576)

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 586)

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 596)

configFastMap :object

Names of simple configuration properties.

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

configOpMap :object

Names of complex configuration properties.

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

currentFrame :number

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

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

<nullable> deathCallback :Phaser.Types.GameObjects.Particles.ParticleDeathCallback

A function to call when a particle dies.

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

<nullable> deathCallbackScope :*

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

<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 554)
See:

defaultFrame :Phaser.Textures.Frame

The default texture frame assigned to particles.

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

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 485)

<nullable> emitCallback :Phaser.Types.GameObjects.Particles.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 422)

<nullable> emitCallbackScope :*

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

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 543)
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 650)
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 662)
See:

frameQuantity :number

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

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

frames :Array.<Phaser.Textures.Frame>

The texture frames assigned to particles.

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

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 495)
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 211)
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 222)
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 390)
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 55)

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 :number

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

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

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 263)

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 273)

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 305)

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 315)

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 325)

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 154)

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 510)

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 522)

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 166)

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 473)
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 198)
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 695)
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 412)

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 345)
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 357)
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 283)
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 294)
See:

texture :Phaser.Textures.Texture

The texture assigned to particles.

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

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 533)

tint :Phaser.GameObjects.Particles.EmitterOp

Color tint applied to emitted particles. Value must not include the alpha channel.

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

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 672)
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 629)
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 176)
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 187)
See:

Methods


atLimit()

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

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1592)
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.

Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas.

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 112)
Returns:

This Geometry Mask that was created.

Type
Phaser.Display.Masks.GeometryMask

depthSort()

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1822)
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 2055)
Returns:

The difference of a and b's y coordinates.

Type
number

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

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

Parameters:
Name Type Argument Default Description
count number <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 1897)
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 number <optional>
this.quantity

The number of Particles to emit.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1880)
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 number

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 1861)
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 Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType <optional>
1

The number of particles to emit at each flow cycle.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1837)
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 Phaser.Types.GameObjects.Particles.ParticleEmitterCallback

The function.

context *

The function's calling context.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1690)
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 Phaser.Types.GameObjects.Particles.ParticleEmitterCallback

The function.

context *

The function's calling context.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1715)
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 Phaser.Types.GameObjects.Particles.ParticleEmitterConfig

Settings for this emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 765)
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 1553)
Returns:

The number of particles with active=true.

Type
number

getDeadParticleCount()

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

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

The number of particles with active=false.

Type
number

getFrame()

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 967)
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 1579)
Returns:

The number of particles, including both alive and dead.

Type
number

killAll()

Deactivates every particle in this emitter.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1669)
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 Phaser.Types.GameObjects.Particles.ParticleDeathCallback

The function.

context * <optional>

The function's calling context.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1637)
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 Phaser.Types.GameObjects.Particles.ParticleEmitterCallback

The function.

context * <optional>

The calling context.

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

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

pause()

Deactivates the emitter.

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

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

preUpdate(time, delta)

Updates this emitter and its particles.

Parameters:
Name Type Description
time number

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 1962)

remove()

Removes the emitter from its manager and the scene.

Since: 3.22.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1807)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

reserve(particleCount)

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

Parameters:
Name Type Description
particleCount number

The number of particles to create.

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

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

resume()

Activates the emitter.

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

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setAlpha(value)

Sets the opacity of emitted particles.

Parameters:
Name Type Description
value Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType

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

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1314)
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 Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType

The angle of the initial velocity of emitted particles.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1365)
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
  • ERASE (only works when rendering to a framebuffer, like a Render Texture)

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 in 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 79)
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 | Phaser.Types.GameObjects.Particles.ParticleEmitterBounds | Phaser.Types.GameObjects.Particles.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 1103)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setDeathZone( [zoneConfig])

Parameters:
Name Type Argument Description
zoneConfig Phaser.Types.GameObjects.Particles.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 1495)
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 Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType

The angle of the initial velocity of emitted particles.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1348)
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 Phaser.Types.GameObjects.Particles.ParticleEmitterEdgeZoneConfig | Phaser.Types.GameObjects.Particles.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 1442)
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 | number | Phaser.Types.GameObjects.Particles.ParticleEmitterFrameConfig

One or more texture frames, or a configuration object.

pickRandom boolean <optional>
true

Whether frames should be assigned at random from frames.

quantity number <optional>
1

The number of consecutive particles that will receive each frame.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1007)
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 Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType <optional>

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

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1416)
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 1295)
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 1261)
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 1278)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setLifespan(value)

Sets the lifespan of newly emitted particles.

Parameters:
Name Type Description
value Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType

The particle lifespan, in ms.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1382)
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 Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType

The x-coordinate of the particle origin.

y Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType

The y-coordinate of the particle origin.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1083)
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 Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType

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

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1399)
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 1064)
Returns:

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setScale(value)

Sets the scale of emitted particles.

Parameters:
Name Type Description
value Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType

The scale, relative to 1.

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

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setScaleX(value)

Sets the horizontal scale of emitted particles.

Parameters:
Name Type Description
value Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType

The scale, relative to 1.

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

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setScaleY(value)

Sets the vertical scale of emitted particles.

Parameters:
Name Type Description
value Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType

The scale, relative to 1.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1226)
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 Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType

The speed, in pixels per second.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1187)
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 Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType

The speed, in pixels per second.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1142)
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 Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType

The speed, in pixels per second.

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

This Particle Emitter.

Type
Phaser.GameObjects.Particles.ParticleEmitter

setTint(value)

Sets the color tint of emitted particles.

Parameters:
Name Type Description
value Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType

A value between 0 and 0xffffff.

Since: 3.22.0
Source: src/gameobjects/particles/ParticleEmitter.js (Line 1331)
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 1740)
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 924)
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 1762)
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 950)
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 874)
Returns:
  • The output object.
Type
object