@@ -11,26 +11,95 @@ var GetFastValue = require('../../utils/object/GetFastValue');
1111var Wrap = require ( '../../math/Wrap' ) ;
1212
1313/**
14- * The returned value sets what the property will be at the START of the particles life, on emit.
14+ * The returned value sets what the property will be at the START of the particle's life, on emit.
1515 * @callback EmitterOpOnEmitCallback
1616 *
17- * @param {Phaser.GameObjects.Particles.Particle } particle - [description]
18- * @param {string } key - [description]
19- * @param {number } value - [description]
17+ * @param {Phaser.GameObjects.Particles.Particle } particle - The particle.
18+ * @param {string } key - The name of the property.
19+ * @param {number } value - The current value of the property.
2020 *
21- * @return {number } [description]
21+ * @return {number } The new value of the property.
2222 */
2323
2424/**
25- * The returned value updates the property for the duration of the particles life.
25+ * The returned value updates the property for the duration of the particle's life.
2626 * @callback EmitterOpOnUpdateCallback
2727 *
28- * @param {Phaser.GameObjects.Particles.Particle } particle - [description]
29- * @param {string } key - [description]
30- * @param {float } t - The T value (between 0 and 1)
31- * @param {number } value - [description]
28+ * @param {Phaser.GameObjects.Particles.Particle } particle - The particle.
29+ * @param {string } key - The name of the property.
30+ * @param {float } t - The normalized lifetime of the particle, between 0 (start) and 1 (end).
31+ * @param {number } value - The current value of the property.
32+ *
33+ * @return {number } The new value of the property.
34+ */
35+
36+ /**
37+ * Defines a value or an operation yielding a value, setting what a particle property will be at the START of the particle's life, on emit.
38+ * @typedef {float|float[]|EmitterOpOnEmitCallback|EmitterOpRandomConfig|EmitterOpRandomMinMaxConfig|EmitterOpRandomStartEndConfig|EmitterOpSteppedConfig|EmitterOpCustomEmitConfig } EmitterOpEmitConfig
39+ *
40+ * @see Phaser.GameObjects.Particles.Particle#fire
41+ */
42+
43+ /**
44+ * Defines an operation yielding a value, updating a particle property for the duration of the particle's life.
45+ * @typedef {EmitterOpOnUpdateCallback|EmitterOpEaseConfig|EmitterOpCustomUpdateConfig } EmitterOpUpdateConfig
46+ *
47+ * @see Phaser.GameObjects.Particles.Particle#update
48+ */
49+
50+ /**
51+ * Defines an operation yielding a random value within a range.
52+ * @typedef {object } EmitterOpRandomConfig
53+ *
54+ * @property {float[] } random - The minimum and maximum values, as [min, max].
55+ */
56+
57+ /**
58+ * Defines an operation yielding a random value within a range.
59+ * @typedef {object } EmitterOpRandomMinMaxConfig
60+ *
61+ * @property {float } min - The minimum value.
62+ * @property {float } max - The maximum value.
63+ */
64+
65+ /**
66+ * Defines an operation yielding a random value within a range.
67+ * @typedef {object } EmitterOpRandomStartEndConfig
68+ *
69+ * @property {float } start - The starting value.
70+ * @property {float } end - The ending value.
71+ * @property {boolean } random - If false, this becomes {@link EmitterOpEaseConfig}.
72+ */
73+
74+ /**
75+ * Defines an operation yielding a value incremented continuously across a range.
76+ * @typedef {object } EmitterOpEaseConfig
77+ *
78+ * @property {float } start - The starting value.
79+ * @property {float } end - The ending value.
80+ * @property {string } [ease='Linear'] - The name of the easing function.
81+ */
82+
83+ /**
84+ * Defines an operation yielding a value incremented by steps across a range.
85+ * @typedef {object } EmitterOpSteppedConfig
3286 *
33- * @return {number } [description]
87+ * @property {number } start - The starting value.
88+ * @property {number } end - The ending value.
89+ * @property {number } steps - The number of steps between start and end.
90+ */
91+
92+ /**
93+ * @typedef {object } EmitterOpCustomEmitConfig
94+ *
95+ * @property {EmitterOpOnEmitCallback } onEmit - [description]
96+ */
97+
98+ /**
99+ * @typedef {object } EmitterOpCustomUpdateConfig
100+ *
101+ * @property {EmitterOpOnEmitCallback } [onEmit] - [description]
102+ * @property {EmitterOpOnUpdateCallback } onUpdate - [description]
34103 */
35104
36105/**
@@ -247,7 +316,7 @@ var EmitterOp = new Class({
247316 // x: 400
248317
249318 this . onEmit = this . staticValueEmit ;
250- this . onUpdate = this . staticValueUpdate ;
319+ this . onUpdate = this . staticValueUpdate ; // How?
251320 }
252321 else if ( Array . isArray ( value ) )
253322 {
@@ -327,6 +396,7 @@ var EmitterOp = new Class({
327396
328397 // x: { start: 100, end: 400, [ ease: 'Linear' ] }
329398
399+
330400 var easeType = this . has ( value , 'ease' ) ? value . ease : 'Linear' ;
331401
332402 this . ease = GetEaseFunction ( easeType ) ;
@@ -336,6 +406,9 @@ var EmitterOp = new Class({
336406 this . onEmit = this . easedValueEmit ;
337407 }
338408
409+ // BUG: alpha, rotate, scaleX, scaleY, or tint are eased here if {min, max} is given.
410+ // Probably this branch should exclude isRandom entirely.
411+
339412 this . onUpdate = this . easeValueUpdate ;
340413 }
341414 }
0 commit comments