A particle emitter represents a single particle stream. It controls a pool of Particles and is controlled by a Particle.
new ParticleEmitter(manager, config)
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. |
Whether accelerationX and accelerationY are non-zero. Set automatically during configuration.
Horizontal acceleration applied to emitted particles, in pixels per second squared.
Vertical acceleration applied to emitted particles, in pixels per second squared.
Whether this emitter updates itself and its particles.
Controlled by Phaser.GameObjects.Particles.ParticleEmitter#pause and Phaser.GameObjects.Particles.ParticleEmitter#resume.
The alpha (transparency) of emitted particles.
The angle of the initial velocity of emitted particles, in degrees.
The blend mode of this emitter's particles.
Whether particles will rebound when they meet the emitter bounds.
A rectangular boundary constraining particle movement.
Whether particles interact with the bottom edge of the emitter Phaser.GameObjects.Particles.ParticleEmitter#bounds.
Whether particles interact with the left edge of the emitter Phaser.GameObjects.Particles.ParticleEmitter#bounds.
Whether particles interact with the right edge of the emitter Phaser.GameObjects.Particles.ParticleEmitter#bounds.
Whether particles interact with the top edge of the emitter Phaser.GameObjects.Particles.ParticleEmitter#bounds.
Names of simple configuration properties.
Names of complex configuration properties.
The current texture frame, as an index of Phaser.GameObjects.Particles.ParticleEmitter#frames.
A function to call when a particle dies.
The calling context for Phaser.GameObjects.Particles.ParticleEmitter#deathCallback.
An object describing a shape that deactivates particles when they interact with it.
The default texture frame assigned to particles.
How many ms to wait after emission before the particles start updating.
A function to call when a particle is emitted.
The calling context for Phaser.GameObjects.Particles.ParticleEmitter#emitCallback.
An object describing a shape to emit particles from.
A Game Object whose position is used as the particle origin.
The offset of the particle origin from the Phaser.GameObjects.Particles.ParticleEmitter#follow target.
The number of consecutive particles that receive a single texture frame (per frame cycle).
The texture frames assigned to particles.
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).
Horizontal acceleration applied to emitted particles, in pixels per second squared.
Vertical acceleration applied to emitted particles, in pixels per second squared.
The lifespan of emitted particles, in ms.
The Emitter Manager this Emitter belongs to.
The Mask this Game Object is using during render.
Set to hard limit the amount of particle objects this emitter is allowed to create. 0 means unlimited.
The maximum horizontal velocity of emitted particles, in pixels per second squared.
The maximum vertical velocity of emitted particles, in pixels per second squared.
Whether moveToX and moveToY are nonzero. Set automatically during configuration.
The x-coordinate emitted particles move toward, when Phaser.GameObjects.Particles.ParticleEmitter#moveTo is true.
The y-coordinate emitted particles move toward, when Phaser.GameObjects.Particles.ParticleEmitter#moveTo is true.
The name of this Particle Emitter.
Empty by default and never populated by Phaser, this is left for developers to use.
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.
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.
The Particle Class which will be emitted by this Emitter.
How many particles are emitted each time particles are emitted (one explosion or one flow cycle).
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.
Whether texture Phaser.GameObjects.Particles.ParticleEmitter#frames are selected at random.
The rotation of emitted particles, in degrees.
The horizontal scale of emitted particles.
The vertical scale of emitted particles.
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.
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.
The initial horizontal speed of emitted particles, in pixels per second.
The initial vertical speed of emitted particles, in pixels per second.
The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal.
Color tint applied to emitted particles. Value must not include the alpha channel.
Whether the emitter's Phaser.GameObjects.Particles.ParticleEmitter#visible state will track the Phaser.GameObjects.Particles.ParticleEmitter#follow target's visibility state.
Set this to false to hide any active particles.
The x-coordinate of the particle origin (where particles will be emitted).
The y-coordinate of the particle origin (where particles will be emitted).
Whether this emitter is at its limit (if set).
Returns true
if this Emitter is at its limit, or false
if no limit, or below the maxParticles
level.
Clears the mask that this Game Object was using.
name | type | arguments | Default | description |
---|---|---|---|---|
destroyMask | boolean | <optional> | false |
Destroy the mask before clearing it? |
This Game Object instance.
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.
name | type | arguments | description |
---|---|---|---|
renderable | Phaser.GameObjects.GameObject | <optional> |
A renderable Game Object that uses a texture, such as a Sprite. |
This Bitmap Mask that was created.
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.
name | type | arguments | description |
---|---|---|---|
graphics | Phaser.GameObjects.Graphics | <optional> |
A Graphics Game Object. The geometry within it will be used as the mask. |
This Geometry Mask that was created.
Sorts active particles with Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback.
This Particle Emitter.
Calculates the difference of two particles, for sorting them by depth.
name | type | description |
---|---|---|
a | object |
The first particle. |
b | object |
The second particle. |
The difference of a and b's y coordinates.
Emits particles at a given position (or the emitter's current position).
name | type | arguments | 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. |
The most recently emitted Particle.
Emits particles at a given position (or the emitter's current position).
name | type | arguments | 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. |
The most recently emitted Particle.
Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once.
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. |
The most recently emitted Particle.
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.
name | type | arguments | 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. |
This Particle Emitter.
Calls a function for each active particle in this emitter.
name | type | description |
---|---|---|
callback | Phaser.Types.GameObjects.Particles.ParticleEmitterCallback |
The function. |
context | * |
The function's calling context. |
This Particle Emitter.
Calls a function for each inactive particle in this emitter.
name | type | description |
---|---|---|
callback | Phaser.Types.GameObjects.Particles.ParticleEmitterCallback |
The function. |
context | * |
The function's calling context. |
This Particle Emitter.
Merges configuration settings into the emitter's current settings.
name | type | description |
---|---|---|
config | Phaser.Types.GameObjects.Particles.ParticleEmitterConfig |
Settings for this emitter. |
This Particle Emitter.
Gets the number of active (in-use) particles in this emitter.
The number of particles with active=true
.
Gets the number of inactive (available) particles in this emitter.
The number of particles with active=false
.
Chooses a texture frame from Phaser.GameObjects.Particles.ParticleEmitter#frames.
The texture frame.
Gets the total number of particles in this emitter.
The number of particles, including both alive and dead.
Deactivates every particle in this emitter.
This Particle Emitter.
Sets a function to call for each particle death.
name | type | arguments | description |
---|---|---|---|
callback | Phaser.Types.GameObjects.Particles.ParticleDeathCallback |
The function. |
|
context | * | <optional> |
The function's calling context. |
This Particle Emitter.
Sets a function to call for each newly emitted particle.
name | type | arguments | description |
---|---|---|---|
callback | Phaser.Types.GameObjects.Particles.ParticleEmitterCallback |
The function. |
|
context | * | <optional> |
The calling context. |
This Particle Emitter.
Updates this emitter and its particles.
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. |
Removes the emitter from its manager and the scene.
This Particle Emitter.
Creates inactive particles and adds them to this emitter's pool.
name | type | description |
---|---|---|
particleCount | number |
The number of particles to create. |
This Particle Emitter.
Sets the opacity of emitted particles.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType |
A value between 0 (transparent) and 1 (opaque). |
This Particle Emitter.
Sets the angle of a Phaser.GameObjects.Particles.ParticleEmitter#radial particle stream.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType |
The angle of the initial velocity of emitted particles. |
This Particle Emitter.
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:
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.
name | type | description |
---|---|---|
value | string | Phaser.BlendModes |
The BlendMode value. Either a string or a CONST. |
This Game Object instance.
Sets or modifies a rectangular boundary constraining the particles.
To remove the boundary, set Phaser.GameObjects.Particles.ParticleEmitter#bounds to null.
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. |
This Particle Emitter.
Sets or removes the Phaser.GameObjects.Particles.ParticleEmitter#deathZone.
name | type | arguments | description |
---|---|---|---|
zoneConfig | Phaser.Types.GameObjects.Particles.ParticleEmitterDeathZoneConfig | <optional> |
An object describing the zone, or |
This Particle Emitter.
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.
name | type | arguments | description |
---|---|---|---|
zoneConfig | Phaser.Types.GameObjects.Particles.ParticleEmitterEdgeZoneConfig | Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig | <optional> |
An object describing the zone, or |
This Particle Emitter.
Sets the angle of a Phaser.GameObjects.Particles.ParticleEmitter#radial particle stream.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType |
The angle of the initial velocity of emitted particles. |
This Particle Emitter.
Sets a pattern for assigning texture frames to emitted particles.
name | type | arguments | 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 |
quantity | number | <optional> | 1 |
The number of consecutive particles that will receive each frame. |
This Particle Emitter.
Sets the emitter's Phaser.GameObjects.Particles.ParticleEmitter#frequency and Phaser.GameObjects.Particles.ParticleEmitter#quantity.
name | type | arguments | 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. |
This Particle Emitter.
Sets the gravity applied to emitted particles.
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. |
This Particle Emitter.
Sets the horizontal gravity applied to emitted particles.
name | type | description |
---|---|---|
value | number |
Acceleration due to gravity, in pixels per second squared. |
This Particle Emitter.
Sets the vertical gravity applied to emitted particles.
name | type | description |
---|---|---|
value | number |
Acceleration due to gravity, in pixels per second squared. |
This Particle Emitter.
Sets the lifespan of newly emitted particles.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType |
The particle lifespan, in ms. |
This Particle Emitter.
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.
name | type | description |
---|---|---|
mask | Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask |
The mask this Game Object will use when rendering. |
This Game Object instance.
Sets the position of the emitter's particle origin. New particles will be emitted here.
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. |
This Particle Emitter.
Sets the number of particles released at each flow cycle or explosion.
name | type | description |
---|---|---|
quantity | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType |
The number of particles to release at each flow cycle or explosion. |
This Particle Emitter.
Turns Phaser.GameObjects.Particles.ParticleEmitter#radial particle movement on or off.
name | type | arguments | Default | description |
---|---|---|---|---|
value | boolean | <optional> | true |
Radial mode (true) or point mode (true). |
This Particle Emitter.
Sets the scale of emitted particles.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType |
The scale, relative to 1. |
This Particle Emitter.
Sets the horizontal scale of emitted particles.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType |
The scale, relative to 1. |
This Particle Emitter.
Sets the vertical scale of emitted particles.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType |
The scale, relative to 1. |
This Particle Emitter.
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.
name | type | arguments | 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 |
This Game Object instance.
Sets the initial radial speed of emitted particles. Changes the emitter to radial mode.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType |
The speed, in pixels per second. |
This Particle Emitter.
Sets the initial horizontal speed of emitted particles. Changes the emitter to point mode.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType |
The speed, in pixels per second. |
This Particle Emitter.
Sets the initial vertical speed of emitted particles. Changes the emitter to point mode.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType |
The speed, in pixels per second. |
This Particle Emitter.
Sets the color tint of emitted particles.
name | type | description |
---|---|---|
value | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType |
A value between 0 and 0xffffff. |
This Particle Emitter.
Sets the visibility of this Game Object.
An invisible Game Object will skip rendering, but will still process update logic.
name | type | description |
---|---|---|
value | boolean |
The visible state of the Game Object. |
This Game Object instance.
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.
This Particle Emitter.
Continuously moves the particle origin to follow a Game Object's position.
name | type | arguments | 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. |
This Particle Emitter.
Stops following a Game Object.
This Particle Emitter.
Creates a description of this emitter suitable for JSON serialization.
name | type | arguments | description |
---|---|---|---|
output | object | <optional> |
An object to copy output into. |