Skip to content

Commit

Permalink
Update ParticleEmitter.js
Browse files Browse the repository at this point in the history
  • Loading branch information
zekeatchan committed Jun 25, 2024
1 parent b49cf68 commit f0f82d3
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/gameobjects/particles/ParticleEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,20 @@ var ParticleEmitter = new Class({
*/
this.particleClass = Particle;

/**
* An internal object holding the configuration for the Emitter.
*
* These are populated as part of the Emitter configuration parsing.
*
* You typically do not access them directly, but instead use the
* `ParticleEmitter.setConfig` or `ParticleEmitter.updateConfig` methods.
*
* @name Phaser.GameObjects.Particles.ParticleEmitter#config
* @type {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig}
* @since 3.90.0
*/
this.config = null;

/**
* An internal object holding all of the EmitterOp instances.
*
Expand Down Expand Up @@ -936,6 +950,8 @@ var ParticleEmitter = new Class({
return this;
}

this.config = config;

var i = 0;
var key = '';

Expand Down Expand Up @@ -1052,6 +1068,38 @@ var ParticleEmitter = new Class({
return this;
},

/**
* Takes an existing Emitter Configuration file and updates this Emitter.
* Existing properties are overriden while new properties are added. The
* updated configuration is then passed to the `setConfig` method to reset
* the Emitter with the updated configuration.
*
* @method Phaser.GameObjects.Particles.ParticleEmitter#updateConfig
* @since 3.60.0
*
* @param {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig} config - Settings for this emitter.
*
* @return {this} This Particle Emitter.
*/
updateConfig: function (config)
{
if (!config)
{
return this;
}

if (!this.config)
{
this.setConfig(config);
}
else
{
this.setConfig({...this.config, ...config});
}

return this;
},

/**
* Creates a description of this emitter suitable for JSON serialization.
*
Expand Down

0 comments on commit f0f82d3

Please sign in to comment.