EmitterColorOp
A specialized emitter op that manages the color property of a Particle over its lifetime. Unlike scalar emitter ops, EmitterColorOp accepts an array of hexadecimal color values (e.g. [0xff0000, 0x00ff00, 0x0000ff]) and smoothly interpolates between them as the particle ages, producing gradient color transitions from birth to death.
The color array is decomposed into separate red, green, and blue component arrays on configuration, and a linear interpolation function is used each update step to recombine them into the current packed RGB color value.
This class is created and managed automatically by the ParticleEmitter when a color property is present in the emitter configuration; you do not normally need to instantiate it directly.
See the ParticleEmitter class for more details on emitter op configuration.
Constructor
new EmitterColorOp(key)
Parameters
| name | type | optional | description |
|---|---|---|---|
| key | string | No | The name of the property. |
Scope: static
Extends
Source: src/gameobjects/particles/EmitterColorOp.js#L14
Since: 3.60.0
Inherited Members
From Phaser.GameObjects.Particles.EmitterOp:
- active
- counter
- current
- defaultValue
- direction
- ease
- emitOnly
- end
- interpolation
- method
- onEmit
- onUpdate
- propertyKey
- propertyValue
- start
- steps
- yoyo
Public Members
b
b: Array.<number>
Description:
An array containing the blue color values.
Populated during the setMethods method.
Source: src/gameobjects/particles/EmitterColorOp.js#L76
Since: 3.60.0
g
g: Array.<number>
Description:
An array containing the green color values.
Populated during the setMethods method.
Source: src/gameobjects/particles/EmitterColorOp.js#L65
Since: 3.60.0
r
r: Array.<number>
Description:
An array containing the red color values.
Populated during the setMethods method.
Source: src/gameobjects/particles/EmitterColorOp.js#L54
Since: 3.60.0
Inherited Methods
From Phaser.GameObjects.Particles.EmitterOp:
- defaultEmit
- defaultUpdate
- destroy
- has
- hasBoth
- hasEither
- loadConfig
- onChange
- proxyEmit
- proxyUpdate
- randomRangedIntEmit
- randomRangedValueEmit
- randomStaticValueEmit
- staticValueEmit
- staticValueUpdate
- steppedEmit
- toJSON
Public Methods
easedValueEmit
<instance> easedValueEmit(particle, key)
Description:
An onEmit callback for an eased property.
It prepares the particle for easing by Phaser.GameObjects.Particles.EmitterColorOp#easeValueUpdate.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| particle | Phaser.GameObjects.Particles.Particle | No | The particle. |
| key | string | No | The name of the property. |
Overrides: Phaser.GameObjects.Particles.EmitterOp#easedValueEmit
Returns: number - Phaser.GameObjects.Particles.EmitterColorOp#start, as the new value of the property.
Source: src/gameobjects/particles/EmitterColorOp.js#L173
Since: 3.60.0
easeValueUpdate
<instance> easeValueUpdate(particle, key, t)
Description:
An onUpdate callback that returns an interpolated packed RGB color value across the configured color array, based on the particle's current normalized lifetime.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| particle | Phaser.GameObjects.Particles.Particle | No | The particle. |
| key | string | No | The name of the property. |
| t | number | No | The current normalized lifetime of the particle, between 0 (birth) and 1 (death). |
Overrides: Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate
Returns: number - The new value of the property.
Source: src/gameobjects/particles/EmitterColorOp.js#L193
Since: 3.60.0
getMethod
<instance> getMethod()
Description:
Checks the type of EmitterOp.propertyValue to determine which method is required in order to return values from this op function.
Overrides: Phaser.GameObjects.Particles.EmitterOp#getMethod
Returns: number - Either 0 if no color property value is set, or 9 if a color array is configured. The result should be passed to setMethods.
Source: src/gameobjects/particles/EmitterColorOp.js#L88
Since: 3.60.0
setEase
<instance> setEase(ease)
Description:
Sets the Ease function to use for Color interpolation.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| ease | string | No | The string-based name of the Ease function to use. |
Source: src/gameobjects/particles/EmitterColorOp.js#L158
Since: 3.60.0
setMethods
<instance> setMethods()
Description:
Configures the emit and update callbacks for this color op based on the current method value. When a color array is present (method 9), it decomposes each packed hex color in propertyValue into separate red, green, and blue component arrays, sets up the linear easing and interpolation functions, and assigns the eased emit and update handlers. If no color value is set (method 0), the default no-op handlers are used.
Overrides: Phaser.GameObjects.Particles.EmitterOp#setMethods
Returns: Phaser.GameObjects.Particles.EmitterColorOp - This Emitter Op object.
Source: src/gameobjects/particles/EmitterColorOp.js#L102
Since: 3.60.0