Phaser API Documentation

  Version: 
Filter

This class is responsible for taking control over the color property in the Particle class and managing its emission and updating functions.

See the ParticleEmitter class for more details on emitter op configuration.

Constructor:

new EmitterColorOp(key)

Parameters:

name type description
key string

The name of the property.

Since: 3.60.0

Extends


Members

Description:

The callback to run for Particles when they are emitted from the Particle Emitter. This is set during setMethods and used by proxyEmit.

Type:
Inherited from: Phaser.GameObjects.Particles.EmitterOp#_onEmit
Since: 3.60.0
Focus
Focus

Description:

The callback to run for Particles when they are updated. This is set during setMethods and used by proxyUpdate.

Type:
Inherited from: Phaser.GameObjects.Particles.EmitterOp#_onUpdate
Since: 3.60.0
Focus
Focus
active: boolean
Focus
Focus

Description:

Set to false to disable this EmitterOp.

Type:
boolean
Inherited from: Phaser.GameObjects.Particles.EmitterOp#active
Since: 3.60.0
Focus
Focus
b: Array.<number>
Focus
Focus

Description:

An array containing the blue color values.

Populated during the setMethods method.

Type:
Array.<number>
Since: 3.60.0
Focus
Focus
counter: number
Focus
Focus

Description:

The step counter for stepped easing, per emit.

Type:
number
Default: 0
Inherited from: Phaser.GameObjects.Particles.EmitterOp#counter
Since: 3.0.0
Focus
Focus
current: number
Focus
Focus

Description:

The most recently calculated value. Updated every time an emission or update method is called. Treat as read-only.

Type:
number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#current
Since: 3.60.0
Focus
Focus

Description:

The default value of this property.

This can be a simple value, an array, a function or an onEmit configuration object.

Type:
Inherited from: Phaser.GameObjects.Particles.EmitterOp#defaultValue
Since: 3.0.0
Focus
Focus
direction: number
Focus
Focus

Description:

The counter direction. 0 for up and 1 for down.

Type:
number
Default: 0
Inherited from: Phaser.GameObjects.Particles.EmitterOp#direction
Since: 3.60.0
Focus
Focus
<nullable> ease: function
Focus
Focus

Description:

The easing function to use for updating this property, if any.

Type:
function
Inherited from: Phaser.GameObjects.Particles.EmitterOp#ease
Since: 3.0.0
Focus
Focus
emitOnly: boolean
Focus
Focus

Description:

Whether this property can only be modified when a Particle is emitted.

Set to true to allow only Phaser.GameObjects.Particles.EmitterOp#onEmit callbacks to be set and affect this property.

Set to false to allow both Phaser.GameObjects.Particles.EmitterOp#onEmit and Phaser.GameObjects.Particles.EmitterOp#onUpdate callbacks to be set and affect this property.

Type:
boolean
Inherited from: Phaser.GameObjects.Particles.EmitterOp#emitOnly
Since: 3.0.0
Focus
Focus
end: number
Focus
Focus

Description:

The end value for this property to ease between.

Type:
number
Default: 0
Inherited from: Phaser.GameObjects.Particles.EmitterOp#end
Since: 3.0.0
Focus
Focus
g: Array.<number>
Focus
Focus

Description:

An array containing the green color values.

Populated during the setMethods method.

Type:
Array.<number>
Since: 3.60.0
Focus
Focus
<nullable> interpolation: function
Focus
Focus

Description:

The interpolation function to use for updating this property, if any.

Type:
function
Inherited from: Phaser.GameObjects.Particles.EmitterOp#interpolation
Since: 3.60.0
Focus
Focus
method: number
Focus
Focus

Description:

The onEmit method type of this EmitterOp.

Set as part of setMethod and cached here to avoid re-setting when only the value changes.

Type:
number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#method
Since: 3.60.0
Focus
Focus

Description:

The callback to run for Particles when they are emitted from the Particle Emitter.

Type:
Inherited from: Phaser.GameObjects.Particles.EmitterOp#onEmit
Since: 3.0.0
Focus
Focus
propertyKey: string
Focus
Focus

Description:

The name of this property.

Type:
string
Inherited from: Phaser.GameObjects.Particles.EmitterOp#propertyKey
Since: 3.0.0
Focus
Focus

Description:

The current value of this property.

This can be a simple value, an array, a function or an onEmit configuration object.

Type:
Inherited from: Phaser.GameObjects.Particles.EmitterOp#propertyValue
Since: 3.0.0
Focus
Focus
r: Array.<number>
Focus
Focus

Description:

An array containing the red color values.

Populated during the setMethods method.

Type:
Array.<number>
Since: 3.60.0
Focus
Focus
start: number | Array.<number>
Focus
Focus

Description:

The start value for this property to ease between.

If an interpolation this holds a reference to the number data array.

Type:
number | Array.<number>
Default: 0
Inherited from: Phaser.GameObjects.Particles.EmitterOp#start
Since: 3.0.0
Focus
Focus
steps: number
Focus
Focus

Description:

The number of steps for stepped easing between Phaser.GameObjects.Particles.EmitterOp#start and Phaser.GameObjects.Particles.EmitterOp#end values, per emit.

Type:
number
Default: 0
Inherited from: Phaser.GameObjects.Particles.EmitterOp#steps
Since: 3.0.0
Focus
Focus
yoyo: boolean
Focus
Focus

Description:

When the step counter reaches it's maximum, should it then yoyo back to the start again, or flip over to it?

Type:
boolean
Default: false
Inherited from: Phaser.GameObjects.Particles.EmitterOp#yoyo
Since: 3.60.0
Focus
Focus

Methods

defaultEmit(particle, key, [value])
Focus
Focus

Description:

The returned value sets what the property will be at the START of the particles life, on emit.

Parameters:

name type arguments description
particle Phaser.GameObjects.Particles.Particle

The particle.

key string

The name of the property.

value number <optional>

The current value of the property.

Returns:
Description:

The new value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#defaultEmit
Since: 3.0.0
Focus
Focus
defaultUpdate(particle, key, t, value)
Focus
Focus

Description:

The returned value updates the property for the duration of the particles life.

Parameters:

name type description
particle Phaser.GameObjects.Particles.Particle

The particle.

key string

The name of the property.

t number

The current normalized lifetime of the particle, between 0 (birth) and 1 (death).

value number

The current value of the property.

Returns:
Description:

The new value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#defaultUpdate
Since: 3.0.0
Focus
Focus
destroy()
Focus
Focus

Description:

Destroys this EmitterOp instance and all of its references.

Called automatically when the ParticleEmitter that owns this EmitterOp is destroyed.

Inherited from: Phaser.GameObjects.Particles.EmitterOp#destroy
Since: 3.60.0
Focus
Focus
easeValueUpdate(particle, key, t)
Focus
Focus

Description:

An onUpdate callback that returns an eased value between the Phaser.GameObjects.Particles.EmitterColorOp#start and Phaser.GameObjects.Particles.EmitterColorOp#end range.

Parameters:

name type description
particle Phaser.GameObjects.Particles.Particle

The particle.

key string

The name of the property.

t number

The current normalized lifetime of the particle, between 0 (birth) and 1 (death).

Returns:
Description:

The new value of the property.

Type:
  • number
Overrides: Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate
Since: 3.60.0
Focus
Focus
easedValueEmit(particle, key)
Focus
Focus

Description:

An onEmit callback for an eased property.

It prepares the particle for easing by Phaser.GameObjects.Particles.EmitterColorOp#easeValueUpdate.

Parameters:

name type description
particle Phaser.GameObjects.Particles.Particle

The particle.

key string

The name of the property.

Returns:
Description:

{@link Phaser.GameObjects.Particles.EmitterColorOp#start}, as the new value of the property.

Type:
  • number
Overrides: Phaser.GameObjects.Particles.EmitterOp#easedValueEmit
Since: 3.60.0
Focus
Focus
getMethod()
Focus
Focus

Description:

Checks the type of EmitterOp.propertyValue to determine which method is required in order to return values from this op function.

Returns:
Description:

A number between 0 and 9 which should be passed to setMethods.

Type:
  • number
Overrides: Phaser.GameObjects.Particles.EmitterOp#getMethod
Since: 3.60.0
Focus
Focus
has(object, key)
Focus
Focus

Description:

Check whether an object has the given property.

Parameters:

name type description
object object

The object to check.

key string

The key of the property to look for in the object.

Returns:
Description:

true if the property exists in the object, false otherwise.

Type:
  • boolean
Inherited from: Phaser.GameObjects.Particles.EmitterOp#has
Since: 3.0.0
Focus
Focus
hasBoth(object, key1, key2)
Focus
Focus

Description:

Check whether an object has both of the given properties.

Parameters:

name type description
object object

The object to check.

key1 string

The key of the first property to check the object for.

key2 string

The key of the second property to check the object for.

Returns:
Description:

true if both properties exist in the object, false otherwise.

Type:
  • boolean
Inherited from: Phaser.GameObjects.Particles.EmitterOp#hasBoth
Since: 3.0.0
Focus
Focus
hasEither(object, key1, key2)
Focus
Focus

Description:

Check whether an object has at least one of the given properties.

Parameters:

name type description
object object

The object to check.

key1 string

The key of the first property to check the object for.

key2 string

The key of the second property to check the object for.

Returns:
Description:

true if at least one of the properties exists in the object, false if neither exist.

Type:
  • boolean
Inherited from: Phaser.GameObjects.Particles.EmitterOp#hasEither
Since: 3.0.0
Focus
Focus
loadConfig([config], [newKey])
Focus
Focus

Description:

Load the property from a Particle Emitter configuration object.

Optionally accepts a new property key to use, replacing the current one.

Parameters:

name type arguments description
config Phaser.Types.GameObjects.Particles.ParticleEmitterConfig <optional>

Settings for the Particle Emitter that owns this property.

newKey string <optional>

The new key to use for this property, if any.

Inherited from: Phaser.GameObjects.Particles.EmitterOp#loadConfig
Since: 3.0.0
Focus
Focus
onChange(value)
Focus
Focus

Description:

Change the current value of the property and update its callback methods.

Parameters:

name type description
value number

The new numeric value of this property.

Returns:
Description:

This Emitter Op object.

Inherited from: Phaser.GameObjects.Particles.EmitterOp#onChange
Since: 3.0.0
Focus
Focus
proxyEmit(particle, key, [value])
Focus
Focus

Description:

The returned value sets what the property will be at the START of the particles life, on emit.

This method is only used when you have provided a custom emit callback.

Parameters:

name type arguments description
particle Phaser.GameObjects.Particles.Particle

The particle.

key string

The name of the property.

value number <optional>

The current value of the property.

Returns:
Description:

The new value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#proxyEmit
Since: 3.60.0
Focus
Focus
proxyUpdate(particle, key, t, value)
Focus
Focus

Description:

The returned value updates the property for the duration of the particles life.

This method is only used when you have provided a custom update callback.

Parameters:

name type description
particle Phaser.GameObjects.Particles.Particle

The particle.

key string

The name of the property.

t number

The current normalized lifetime of the particle, between 0 (birth) and 1 (death).

value number

The current value of the property.

Returns:
Description:

The new value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#proxyUpdate
Since: 3.60.0
Focus
Focus
randomRangedIntEmit(particle, key)
Focus
Focus

Description:

An onEmit callback that returns a value between the Phaser.GameObjects.Particles.EmitterOp#start and Phaser.GameObjects.Particles.EmitterOp#end range.

Parameters:

name type description
particle Phaser.GameObjects.Particles.Particle

The particle.

key string

The key of the property.

Returns:
Description:

The new value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#randomRangedIntEmit
Since: 3.60.0
Focus
Focus
randomRangedValueEmit(particle, key)
Focus
Focus

Description:

An onEmit callback that returns a value between the Phaser.GameObjects.Particles.EmitterOp#start and Phaser.GameObjects.Particles.EmitterOp#end range.

Parameters:

name type description
particle Phaser.GameObjects.Particles.Particle

The particle.

key string

The key of the property.

Returns:
Description:

The new value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit
Since: 3.0.0
Focus
Focus
randomStaticValueEmit()
Focus
Focus

Description:

An onEmit callback that returns a random value from the current value array.

Returns:
Description:

The new value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit
Since: 3.0.0
Focus
Focus
setEase(ease)
Focus
Focus

Description:

Sets the Ease function to use for Color interpolation.

Parameters:

name type description
ease string

The string-based name of the Ease function to use.

Since: 3.60.0
Focus
Focus
setMethods()
Focus
Focus

Description:

Sets the EmitterColorOp method values, if in use.

Returns:
Description:

This Emitter Op object.

Overrides: Phaser.GameObjects.Particles.EmitterOp#setMethods
Since: 3.60.0
Focus
Focus
staticValueEmit()
Focus
Focus

Description:

An onEmit callback that returns the current value of the property.

Returns:
Description:

The current value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#staticValueEmit
Since: 3.0.0
Focus
Focus
staticValueUpdate()
Focus
Focus

Description:

An onUpdate callback that returns the current value of the property.

Returns:
Description:

The current value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate
Since: 3.0.0
Focus
Focus
steppedEmit()
Focus
Focus

Description:

An onEmit callback that returns a stepped value between the Phaser.GameObjects.Particles.EmitterOp#start and Phaser.GameObjects.Particles.EmitterOp#end range.

Returns:
Description:

The new value of the property.

Type:
  • number
Inherited from: Phaser.GameObjects.Particles.EmitterOp#steppedEmit
Since: 3.0.0
Focus
Focus
toJSON()
Focus
Focus

Description:

Build a JSON representation of this Particle Emitter property.

Returns:
Description:

A JSON representation of this Particle Emitter property.

Type:
  • object
Inherited from: Phaser.GameObjects.Particles.EmitterOp#toJSON
Since: 3.0.0
Focus
Focus