Skip to content

Commit 645f1e6

Browse files
committed
Added jsdocs
1 parent 2d4b7b5 commit 645f1e6

1 file changed

Lines changed: 262 additions & 2 deletions

File tree

src/gameobjects/particles/EmitterOp.js

Lines changed: 262 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ var GetEaseFunction = require('../../tweens/builder/GetEaseFunction');
44
var GetFastValue = require('../../utils/object/GetFastValue');
55
var Wrap = require('../../math/Wrap');
66

7+
/**
8+
* [description]
9+
*
10+
* @class EmitterOp
11+
* @memberOf Phaser.GameObjects.Particles
12+
* @constructor
13+
* @since 3.0.0
14+
*
15+
* @param {object} config - [description]
16+
* @param {string} key - [description]
17+
* @param {number} defaultValue - [description]
18+
* @param {boolean} [emitOnly=false] - [description]
19+
*/
720
var EmitterOp = new Class({
821

922
initialize:
@@ -12,25 +25,121 @@ var EmitterOp = new Class({
1225
{
1326
if (emitOnly === undefined) { emitOnly = false; }
1427

28+
/**
29+
* [description]
30+
*
31+
* @name Phaser.GameObjects.Particles.EmitterOp#propertyKey
32+
* @type {string}
33+
* @since 3.0.0
34+
*/
1535
this.propertyKey = key;
36+
37+
/**
38+
* [description]
39+
*
40+
* @name Phaser.GameObjects.Particles.EmitterOp#propertyValue
41+
* @type {number}
42+
* @since 3.0.0
43+
*/
1644
this.propertyValue = defaultValue;
45+
46+
/**
47+
* [description]
48+
*
49+
* @name Phaser.GameObjects.Particles.EmitterOp#defaultValue
50+
* @type {number}
51+
* @since 3.0.0
52+
*/
1753
this.defaultValue = defaultValue;
1854

55+
/**
56+
* [description]
57+
*
58+
* @name Phaser.GameObjects.Particles.EmitterOp#steps
59+
* @type {number}
60+
* @default 0
61+
* @since 3.0.0
62+
*/
1963
this.steps = 0;
64+
65+
/**
66+
* [description]
67+
*
68+
* @name Phaser.GameObjects.Particles.EmitterOp#counter
69+
* @type {number}
70+
* @default 0
71+
* @since 3.0.0
72+
*/
2073
this.counter = 0;
2174

75+
/**
76+
* [description]
77+
*
78+
* @name Phaser.GameObjects.Particles.EmitterOp#start
79+
* @type {number}
80+
* @default 0
81+
* @since 3.0.0
82+
*/
2283
this.start = 0;
84+
85+
/**
86+
* [description]
87+
*
88+
* @name Phaser.GameObjects.Particles.EmitterOp#end
89+
* @type {number}
90+
* @default 0
91+
* @since 3.0.0
92+
*/
2393
this.end = 0;
94+
95+
/**
96+
* [description]
97+
*
98+
* @name Phaser.GameObjects.Particles.EmitterOp#ease
99+
* @type {?function}
100+
* @since 3.0.0
101+
*/
24102
this.ease;
25103

104+
/**
105+
* [description]
106+
*
107+
* @name Phaser.GameObjects.Particles.EmitterOp#emitOnly
108+
* @type {boolean}
109+
* @since 3.0.0
110+
*/
26111
this.emitOnly = emitOnly;
27112

113+
/**
114+
* [description]
115+
*
116+
* @name Phaser.GameObjects.Particles.EmitterOp#onEmit
117+
* @type {[type]}
118+
* @since 3.0.0
119+
*/
28120
this.onEmit = this.defaultEmit;
121+
122+
/**
123+
* [description]
124+
*
125+
* @name Phaser.GameObjects.Particles.EmitterOp#onUpdate
126+
* @type {[type]}
127+
* @since 3.0.0
128+
*/
29129
this.onUpdate = this.defaultUpdate;
30130

31131
this.loadConfig(config);
32132
},
33133

134+
/**
135+
* [description]
136+
*
137+
* @method Phaser.GameObjects.Particles.EmitterOp#loadConfig
138+
* @since 3.0.0
139+
*
140+
* @param {object} config - [description]
141+
* @param {string} newKey - [description]
142+
*/
34143
loadConfig: function (config, newKey)
35144
{
36145
if (config === undefined) { config = {}; }
@@ -51,18 +160,44 @@ var EmitterOp = new Class({
51160
}
52161
},
53162

163+
/**
164+
* [description]
165+
*
166+
* @method Phaser.GameObjects.Particles.EmitterOp#toJSON
167+
* @since 3.0.0
168+
*
169+
* @return {object} [description]
170+
*/
54171
toJSON: function ()
55172
{
56173
return JSON.stringify(this.propertyValue);
57174
},
58175

176+
/**
177+
* [description]
178+
*
179+
* @method Phaser.GameObjects.Particles.EmitterOp#onChange
180+
* @since 3.0.0
181+
*
182+
* @param {[type]} value - [description]
183+
*
184+
* @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object.
185+
*/
59186
onChange: function (value)
60187
{
61188
this.propertyValue = value;
62189

63190
return this.setMethods();
64191
},
65192

193+
/**
194+
* [description]
195+
*
196+
* @method Phaser.GameObjects.Particles.EmitterOp#setMethods
197+
* @since 3.0.0
198+
*
199+
* @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object.
200+
*/
66201
setMethods: function ()
67202
{
68203
var value = this.propertyValue;
@@ -195,50 +330,143 @@ var EmitterOp = new Class({
195330
return this;
196331
},
197332

333+
/**
334+
* [description]
335+
*
336+
* @method Phaser.GameObjects.Particles.EmitterOp#has
337+
* @since 3.0.0
338+
*
339+
* @param {object} object - [description]
340+
* @param {string} key - [description]
341+
*
342+
* @return {boolean} [description]
343+
*/
198344
has: function (object, key)
199345
{
200346
return (object.hasOwnProperty(key));
201347
},
202348

349+
/**
350+
* [description]
351+
*
352+
* @method Phaser.GameObjects.Particles.EmitterOp#hasBoth
353+
* @since 3.0.0
354+
*
355+
* @param {object} object - [description]
356+
* @param {string} key1 - [description]
357+
* @param {string} key2 - [description]
358+
*
359+
* @return {boolean} [description]
360+
*/
203361
hasBoth: function (object, key1, key2)
204362
{
205363
return (object.hasOwnProperty(key1) && object.hasOwnProperty(key2));
206364
},
207365

366+
/**
367+
* [description]
368+
*
369+
* @method Phaser.GameObjects.Particles.EmitterOp#hasEither
370+
* @since 3.0.0
371+
*
372+
* @param {object} object - [description]
373+
* @param {string} key1 - [description]
374+
* @param {string} key2 - [description]
375+
*
376+
* @return {boolean} [description]
377+
*/
208378
hasEither: function (object, key1, key2)
209379
{
210380
return (object.hasOwnProperty(key1) || object.hasOwnProperty(key2));
211381
},
212382

213-
// The returned value sets what the property will be at the START of the particles life, on emit
383+
/**
384+
* The returned value sets what the property will be at the START of the particles life, on emit.
385+
*
386+
* @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit
387+
* @since 3.0.0
388+
*
389+
* @param {Phaser.GameObjects.Particles.Particle} particle - [description]
390+
* @param {string} key - [description]
391+
* @param {number} value - [description]
392+
*
393+
* @return {number} [description]
394+
*/
214395
defaultEmit: function (particle, key, value)
215396
{
216397
return value;
217398
},
218399

219-
// The returned value updates the property for the duration of the particles life
400+
/**
401+
* The returned value updates the property for the duration of the particles life.
402+
*
403+
* @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate
404+
* @since 3.0.0
405+
*
406+
* @param {Phaser.GameObjects.Particles.Particle} particle - [description]
407+
* @param {string} key - [description]
408+
* @param {float} t - The T value (between 0 and 1)
409+
* @param {number} value - [description]
410+
*
411+
* @return {number} [description]
412+
*/
220413
defaultUpdate: function (particle, key, t, value)
221414
{
222415
return value;
223416
},
224417

418+
/**
419+
* [description]
420+
*
421+
* @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit
422+
* @since 3.0.0
423+
*
424+
* @return {number} [description]
425+
*/
225426
staticValueEmit: function ()
226427
{
227428
return this.propertyValue;
228429
},
229430

431+
/**
432+
* [description]
433+
*
434+
* @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate
435+
* @since 3.0.0
436+
*
437+
* @return {number} [description]
438+
*/
230439
staticValueUpdate: function ()
231440
{
232441
return this.propertyValue;
233442
},
234443

444+
/**
445+
* [description]
446+
*
447+
* @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit
448+
* @since 3.0.0
449+
*
450+
* @return {number} [description]
451+
*/
235452
randomStaticValueEmit: function ()
236453
{
237454
var randomIndex = Math.floor(Math.random() * this.propertyValue.length);
238455

239456
return this.propertyValue[randomIndex];
240457
},
241458

459+
/**
460+
* [description]
461+
*
462+
* @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit
463+
* @since 3.0.0
464+
*
465+
* @param {Phaser.GameObjects.Particles.Particle} particle - [description]
466+
* @param {string} key - [description]
467+
*
468+
* @return {number} [description]
469+
*/
242470
randomRangedValueEmit: function (particle, key)
243471
{
244472
var value = FloatBetween(this.start, this.end);
@@ -251,6 +479,14 @@ var EmitterOp = new Class({
251479
return value;
252480
},
253481

482+
/**
483+
* [description]
484+
*
485+
* @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit
486+
* @since 3.0.0
487+
*
488+
* @return {number} [description]
489+
*/
254490
steppedEmit: function ()
255491
{
256492
var current = this.counter;
@@ -262,6 +498,17 @@ var EmitterOp = new Class({
262498
return current;
263499
},
264500

501+
/**
502+
* [description]
503+
*
504+
* @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit
505+
* @since 3.0.0
506+
*
507+
* @param {Phaser.GameObjects.Particles.Particle} particle - [description]
508+
* @param {string} key - [description]
509+
*
510+
* @return {number} [description]
511+
*/
265512
easedValueEmit: function (particle, key)
266513
{
267514
if (particle && particle.data[key])
@@ -275,6 +522,19 @@ var EmitterOp = new Class({
275522
return this.start;
276523
},
277524

525+
/**
526+
* [description]
527+
*
528+
* @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate
529+
* @since 3.0.0
530+
*
531+
* @param {Phaser.GameObjects.Particles.Particle} particle - [description]
532+
* @param {string} key - [description]
533+
* @param {float} t - The T value (between 0 and 1)
534+
* @param {number} value - [description]
535+
*
536+
* @return {number} [description]
537+
*/
278538
easeValueUpdate: function (particle, key, t, value)
279539
{
280540
var data = particle.data[key];

0 commit comments

Comments
 (0)