1 /****************************************************************************
  2  Copyright (c) 2008-2010 Ricardo Quesada
  3  Copyright (c) 2011-2012 cocos2d-x.org
  4  Copyright (c) 2013-2014 Chukong Technologies Inc.
  5 
  6  http://www.cocos2d-x.org
  7 
  8  Permission is hereby granted, free of charge, to any person obtaining a copy
  9  of this software and associated documentation files (the "Software"), to deal
 10  in the Software without restriction, including without limitation the rights
 11  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 12  copies of the Software, and to permit persons to whom the Software is
 13  furnished to do so, subject to the following conditions:
 14 
 15  The above copyright notice and this permission notice shall be included in
 16  all copies or substantial portions of the Software.
 17 
 18  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 19  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 20  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 21  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 22  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 24  THE SOFTWARE.
 25  ****************************************************************************/
 26 
 27 /**
 28  * A fire particle system
 29  * @class
 30  * @extends cc.ParticleSystem
 31  *
 32  * @example
 33  * var emitter = new cc.ParticleFire();
 34  */
 35 cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{
 36     /**
 37      * <p>The cc.ParticleFire's constructor. <br/>
 38      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleFire()".<br/>
 39      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
 40      */
 41     ctor:function () {
 42         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 300 : 150);
 43     },
 44 
 45     /**
 46      * initialize a fire particle system with number Of Particles
 47      * @param {Number} numberOfParticles
 48      * @return {Boolean}
 49      */
 50     initWithTotalParticles:function (numberOfParticles) {
 51         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
 52             // duration
 53             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
 54 
 55             // Gravity Mode
 56             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
 57 
 58 
 59             // Gravity Mode: gravity
 60             this.setGravity(cc.p(0, 0));
 61 
 62             // Gravity Mode: radial acceleration
 63             this.setRadialAccel(0);
 64             this.setRadialAccelVar(0);
 65 
 66             // Gravity Mode: speed of particles
 67             this.setSpeed(60);
 68             this.setSpeedVar(20);
 69 
 70             // starting angle
 71             this.setAngle(90);
 72             this.setAngleVar(10);
 73 
 74             // emitter position
 75             var winSize = cc.director.getWinSize();
 76             this.setPosition(winSize.width / 2, 60);
 77             this.setPosVar(cc.p(40, 20));
 78 
 79             // life of particles
 80             this.setLife(3);
 81             this.setLifeVar(0.25);
 82 
 83 
 84             // size, in pixels
 85             this.setStartSize(54.0);
 86             this.setStartSizeVar(10.0);
 87             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
 88 
 89             // emits per frame
 90             this.setEmissionRate(this.getTotalParticles() / this.getLife());
 91 
 92             // color of particles
 93             this.setStartColor(cc.color(194,64,31,255));
 94             this.setStartColorVar(cc.color(0,0,0,0));
 95             this.setEndColor(cc.color(0,0,0,255));
 96             this.setEndColorVar(cc.color(0,0,0,0));
 97 
 98             // additive
 99             this.setBlendAdditive(true);
100             return true;
101         }
102         return false;
103     }
104 });
105 
106 /**
107  * Create a fire particle system
108  * @deprecated since v3.0 please use new cc.ParticleFire() instead
109  * @return {cc.ParticleFire}
110  */
111 cc.ParticleFire.create = function () {
112     return new cc.ParticleFire();
113 };
114 
115 /**
116  * A fireworks particle system
117  * @class
118  * @extends cc.ParticleSystem
119  *
120  * @example
121  * var emitter = new cc.ParticleFireworks();
122  */
123 cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks# */{
124     /**
125      * <p>The cc.ParticleFireworks's constructor. <br/>
126      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleFireworks()".<br/>
127      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
128      */
129     ctor:function () {
130         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 1500 : 150);
131     },
132 
133     /**
134      * initialize a fireworks particle system with number Of Particles
135      * @param {Number} numberOfParticles
136      * @return {Boolean}
137      */
138     initWithTotalParticles:function (numberOfParticles) {
139         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
140             // duration
141             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
142 
143             // Gravity Mode
144             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
145 
146             // Gravity Mode: gravity
147             this.setGravity(cc.p(0, -90));
148 
149             // Gravity Mode:  radial
150             this.setRadialAccel(0);
151             this.setRadialAccelVar(0);
152 
153             //  Gravity Mode: speed of particles
154             this.setSpeed(180);
155             this.setSpeedVar(50);
156 
157             // emitter position
158             var winSize = cc.director.getWinSize();
159             this.setPosition(winSize.width / 2, winSize.height / 2);
160 
161             // angle
162             this.setAngle(90);
163             this.setAngleVar(20);
164 
165             // life of particles
166             this.setLife(3.5);
167             this.setLifeVar(1);
168 
169             // emits per frame
170             this.setEmissionRate(this.getTotalParticles() / this.getLife());
171 
172             // color of particles
173             this.setStartColor(cc.color(128,128,128,255));
174             this.setStartColorVar(cc.color(128,128,128,255));
175             this.setEndColor(cc.color(26,26,26,51));
176             this.setEndColorVar(cc.color(26,26,26,51));
177 
178             // size, in pixels
179             this.setStartSize(8.0);
180             this.setStartSizeVar(2.0);
181             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
182 
183             // additive
184             this.setBlendAdditive(false);
185             return true;
186         }
187         return false;
188     }
189 });
190 
191 /**
192  * Create a fireworks particle system
193  * @deprecated since v3.0 please use new cc.ParticleFireworks() instead.
194  * @return {cc.ParticleFireworks}
195  */
196 cc.ParticleFireworks.create = function () {
197     return new cc.ParticleFireworks();
198 };
199 
200 /**
201  * A sun particle system
202  * @class
203  * @extends cc.ParticleSystem
204  *
205  * @example
206  * var emitter = new cc.ParticleSun();
207  */
208 cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{
209     /**
210      * <p>The cc.ParticleSun's constructor. <br/>
211      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSun()".<br/>
212      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
213      */
214     ctor:function () {
215         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 350 : 150);
216     },
217 
218     /**
219      * initialize a sun particle system with number Of Particles
220      * @param {Number} numberOfParticles
221      * @return {Boolean}
222      */
223     initWithTotalParticles:function (numberOfParticles) {
224         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
225             // additive
226             this.setBlendAdditive(true);
227 
228             // duration
229             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
230 
231             // Gravity Mode
232             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
233 
234             // Gravity Mode: gravity
235             this.setGravity(cc.p(0, 0));
236 
237             // Gravity mode: radial acceleration
238             this.setRadialAccel(0);
239             this.setRadialAccelVar(0);
240 
241             // Gravity mode: speed of particles
242             this.setSpeed(20);
243             this.setSpeedVar(5);
244 
245             // angle
246             this.setAngle(90);
247             this.setAngleVar(360);
248 
249             // emitter position
250             var winSize = cc.director.getWinSize();
251             this.setPosition(winSize.width / 2, winSize.height / 2);
252             this.setPosVar(cc.p(0,0));
253 
254             // life of particles
255             this.setLife(1);
256             this.setLifeVar(0.5);
257 
258             // size, in pixels
259             this.setStartSize(30.0);
260             this.setStartSizeVar(10.0);
261             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
262 
263             // emits per seconds
264             this.setEmissionRate(this.getTotalParticles() / this.getLife());
265 
266             // color of particles
267             this.setStartColor(cc.color(194, 64, 31, 255));
268             this.setStartColorVar(cc.color(0, 0, 0, 0));
269             this.setEndColor(cc.color(0, 0, 0, 255));
270             this.setEndColorVar(cc.color(0, 0, 0, 0));
271 
272             return true;
273         }
274         return false;
275     }
276 });
277 
278 /**
279  * Create a sun particle system
280  * @deprecated since v3.0 please use new cc.ParticleSun() instead.
281  * @return {cc.ParticleSun}
282  */
283 cc.ParticleSun.create = function () {
284     return new cc.ParticleSun();
285 };
286 
287 //! @brief A  particle system
288 /**
289  * A galaxy particle system
290  * @class
291  * @extends cc.ParticleSystem
292  *
293  * @example
294  * var emitter = new cc.ParticleGalaxy();
295  */
296 cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{
297     /**
298      * <p>The cc.ParticleGalaxy's constructor. <br/>
299      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleGalaxy()".<br/>
300      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
301      */
302     ctor:function () {
303         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 200 : 100);
304     },
305 
306     /**
307      * initialize a galaxy particle system with number Of Particles
308      * @param {Number} numberOfParticles
309      * @return {Boolean}
310      */
311     initWithTotalParticles:function (numberOfParticles) {
312         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
313             // duration
314             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
315 
316             // Gravity Mode
317             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
318 
319             // Gravity Mode: gravity
320             this.setGravity(cc.p(0, 0));
321 
322             // Gravity Mode: speed of particles
323             this.setSpeed(60);
324             this.setSpeedVar(10);
325 
326             // Gravity Mode: radial
327             this.setRadialAccel(-80);
328             this.setRadialAccelVar(0);
329 
330             // Gravity Mode: tangential
331             this.setTangentialAccel(80);
332             this.setTangentialAccelVar(0);
333 
334             // angle
335             this.setAngle(90);
336             this.setAngleVar(360);
337 
338             // emitter position
339             var winSize = cc.director.getWinSize();
340             this.setPosition(winSize.width / 2, winSize.height / 2);
341             this.setPosVar(cc.p(0,0));
342 
343             // life of particles
344             this.setLife(4);
345             this.setLifeVar(1);
346 
347             // size, in pixels
348             this.setStartSize(37.0);
349             this.setStartSizeVar(10.0);
350             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
351 
352             // emits per second
353             this.setEmissionRate(this.getTotalParticles() / this.getLife());
354 
355             // color of particles
356             this.setStartColor(cc.color(31, 64, 194, 255));
357             this.setStartColorVar(cc.color(0, 0, 0, 0));
358             this.setEndColor(cc.color(0, 0, 0, 255));
359             this.setEndColorVar(cc.color(0, 0, 0, 0));
360 
361             // additive
362             this.setBlendAdditive(true);
363             return true;
364         }
365         return false;
366     }
367 });
368 /**
369  * Create a galaxy particle system
370  * @deprecated since v3.0 please use new cc.OarticleGalaxy() instead.
371  * @return {cc.ParticleGalaxy}
372  */
373 cc.ParticleGalaxy.create = function () {
374     return new cc.ParticleGalaxy();
375 };
376 
377 /**
378  * A flower particle system
379  * @class
380  * @extends cc.ParticleSystem
381  *
382  * @example
383  * var emitter = new cc.ParticleFlower();
384  */
385 cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{
386     /**
387      * <p>The cc.ParticleFlower's constructor. <br/>
388      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleFlower()".<br/>
389      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
390      */
391     ctor : function () {
392         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 250 : 100);
393     },
394 
395     /**
396      * initialize a flower particle system with number Of Particles
397      * @param {Number} numberOfParticles
398      * @return {Boolean}
399      */
400     initWithTotalParticles:function (numberOfParticles) {
401         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
402             // duration
403             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
404 
405             // Gravity Mode
406             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
407 
408             // Gravity Mode: gravity
409             this.setGravity(cc.p(0, 0));
410 
411             // Gravity Mode: speed of particles
412             this.setSpeed(80);
413             this.setSpeedVar(10);
414 
415             // Gravity Mode: radial
416             this.setRadialAccel(-60);
417             this.setRadialAccelVar(0);
418 
419             // Gravity Mode: tangential
420             this.setTangentialAccel(15);
421             this.setTangentialAccelVar(0);
422 
423             // angle
424             this.setAngle(90);
425             this.setAngleVar(360);
426 
427             // emitter position
428             var winSize = cc.director.getWinSize();
429             this.setPosition(winSize.width / 2, winSize.height / 2);
430             this.setPosVar(cc.p(0,0));
431 
432             // life of particles
433             this.setLife(4);
434             this.setLifeVar(1);
435 
436             // size, in pixels
437             this.setStartSize(30.0);
438             this.setStartSizeVar(10.0);
439             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
440 
441             // emits per second
442             this.setEmissionRate(this.getTotalParticles() / this.getLife());
443 
444             // color of particles
445             this.setStartColor(cc.color(128, 128, 128, 255));
446             this.setStartColorVar(cc.color(128, 128, 128, 128));
447             this.setEndColor(cc.color(0, 0, 0, 255));
448             this.setEndColorVar(cc.color(0, 0, 0, 0));
449 
450             // additive
451             this.setBlendAdditive(true);
452             return true;
453         }
454         return false;
455     }
456 });
457 
458 /**
459  * Create a flower particle system
460  * @deprecated since v3.0 please use new cc.ParticleFlower() instead.
461  * @return {cc.ParticleFlower}
462  */
463 cc.ParticleFlower.create = function () {
464     return new cc.ParticleFlower();
465 };
466 
467 //! @brief A meteor particle system
468 /**
469  * A meteor particle system
470  * @class
471  * @extends cc.ParticleSystem
472  *
473  * @example
474  * var emitter = new cc.ParticleMeteor();
475  */
476 cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{
477     /**
478      * <p>The cc.ParticleMeteor's constructor. <br/>
479      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleMeteor()".<br/>
480      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
481      */
482     ctor:function () {
483         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 150 : 100);
484     },
485 
486     /**
487      * initialize a meteor particle system with number Of Particles
488      * @param {Number} numberOfParticles
489      * @return {Boolean}
490      */
491     initWithTotalParticles:function (numberOfParticles) {
492         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
493             // duration
494             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
495 
496             // Gravity Mode
497             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
498 
499             // Gravity Mode: gravity
500             this.setGravity(cc.p(-200, 200));
501 
502             // Gravity Mode: speed of particles
503             this.setSpeed(15);
504             this.setSpeedVar(5);
505 
506             // Gravity Mode: radial
507             this.setRadialAccel(0);
508             this.setRadialAccelVar(0);
509 
510             // Gravity Mode: tangential
511             this.setTangentialAccel(0);
512             this.setTangentialAccelVar(0);
513 
514             // angle
515             this.setAngle(90);
516             this.setAngleVar(360);
517 
518             // emitter position
519             var winSize = cc.director.getWinSize();
520             this.setPosition(winSize.width / 2, winSize.height / 2);
521             this.setPosVar(cc.p(0,0));
522 
523             // life of particles
524             this.setLife(2);
525             this.setLifeVar(1);
526 
527             // size, in pixels
528             this.setStartSize(60.0);
529             this.setStartSizeVar(10.0);
530             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
531 
532             // emits per second
533             this.setEmissionRate(this.getTotalParticles() / this.getLife());
534 
535             // color of particles
536             this.setStartColor(cc.color(51, 102, 179));
537             this.setStartColorVar(cc.color(0, 0, 51, 26));
538             this.setEndColor(cc.color(0, 0, 0, 255));
539             this.setEndColorVar(cc.color(0, 0, 0, 0));
540 
541             // additive
542             this.setBlendAdditive(true);
543             return true;
544         }
545         return false;
546     }
547 });
548 
549 /**
550  * Create a meteor particle system
551  * @deprecated since v3.0 please use new cc.ParticleMeteor() instead.
552  * @return {cc.ParticleMeteor}
553  */
554 cc.ParticleMeteor.create = function () {
555     return new cc.ParticleMeteor();
556 };
557 
558 /**
559  * A spiral particle system
560  * @class
561  * @extends cc.ParticleSystem
562  *
563  * @example
564  * var emitter = new cc.ParticleSpiral();
565  */
566 cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{
567 
568     /**
569      * <p>The cc.ParticleSpiral's constructor. <br/>
570      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSpiral()".<br/>
571      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
572      */
573     ctor:function() {
574         cc.ParticleSystem.prototype.ctor.call(this,(cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 500 : 100);
575     },
576 
577     /**
578      * initialize a spiral particle system with number Of Particles
579      * @param {Number} numberOfParticles
580      * @return {Boolean}
581      */
582     initWithTotalParticles:function (numberOfParticles) {
583         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
584             // duration
585             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
586 
587             // Gravity Mode
588             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
589 
590             // Gravity Mode: gravity
591             this.setGravity(cc.p(0, 0));
592 
593             // Gravity Mode: speed of particles
594             this.setSpeed(150);
595             this.setSpeedVar(0);
596 
597             // Gravity Mode: radial
598             this.setRadialAccel(-380);
599             this.setRadialAccelVar(0);
600 
601             // Gravity Mode: tangential
602             this.setTangentialAccel(45);
603             this.setTangentialAccelVar(0);
604 
605             // angle
606             this.setAngle(90);
607             this.setAngleVar(0);
608 
609             // emitter position
610             var winSize = cc.director.getWinSize();
611             this.setPosition(winSize.width / 2, winSize.height / 2);
612             this.setPosVar(cc.p(0,0));
613 
614             // life of particles
615             this.setLife(12);
616             this.setLifeVar(0);
617 
618             // size, in pixels
619             this.setStartSize(20.0);
620             this.setStartSizeVar(0.0);
621             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
622 
623             // emits per second
624             this.setEmissionRate(this.getTotalParticles() / this.getLife());
625 
626             // color of particles
627             this.setStartColor(cc.color(128,128,128,255));
628             this.setStartColorVar(cc.color(128,128,128,0));
629             this.setEndColor(cc.color(128,128,128,255));
630             this.setEndColorVar(cc.color(128,128,128,0));
631 
632             // additive
633             this.setBlendAdditive(false);
634             return true;
635         }
636         return false;
637     }
638 });
639 
640 /**
641  * Create a spiral particle system
642  * @deprecated since v3.0 please use new cc.ParticleSpiral() instead.
643  * @return {cc.ParticleSpiral}
644  */
645 cc.ParticleSpiral.create = function () {
646     return new cc.ParticleSpiral();
647 };
648 
649 /**
650  * An explosion particle system
651  * @class
652  * @extends cc.ParticleSystem
653  *
654  * @example
655  * var emitter = new cc.ParticleExplosion();
656  */
657 cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion# */{
658     /**
659      * <p>The cc.ParticleExplosion's constructor. <br/>
660      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleExplosion()".<br/>
661      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
662      */
663     ctor:function () {
664         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 700 : 300);
665     },
666 
667     /**
668      * initialize an explosion particle system with number Of Particles
669      * @param {Number} numberOfParticles
670      * @return {Boolean}
671      */
672     initWithTotalParticles:function (numberOfParticles) {
673         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
674             // duration
675             this.setDuration(0.1);
676 
677             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
678 
679             // Gravity Mode: gravity
680             this.setGravity(cc.p(0, 0));
681 
682             // Gravity Mode: speed of particles
683             this.setSpeed(70);
684             this.setSpeedVar(40);
685 
686             // Gravity Mode: radial
687             this.setRadialAccel(0);
688             this.setRadialAccelVar(0);
689 
690             // Gravity Mode: tangential
691             this.setTangentialAccel(0);
692             this.setTangentialAccelVar(0);
693 
694             // angle
695             this.setAngle(90);
696             this.setAngleVar(360);
697 
698             // emitter position
699             var winSize = cc.director.getWinSize();
700             this.setPosition(winSize.width / 2, winSize.height / 2);
701             this.setPosVar(cc.p(0,0));
702 
703             // life of particles
704             this.setLife(5.0);
705             this.setLifeVar(2);
706 
707             // size, in pixels
708             this.setStartSize(15.0);
709             this.setStartSizeVar(10.0);
710             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
711 
712             // emits per second
713             this.setEmissionRate(this.getTotalParticles() / this.getDuration());
714 
715             // color of particles
716             this.setStartColor(cc.color(179, 26, 51, 255));
717             this.setStartColorVar(cc.color(128, 128, 128, 0));
718             this.setEndColor(cc.color(128, 128, 128, 0));
719             this.setEndColorVar(cc.color(128, 128, 128, 0));
720 
721             // additive
722             this.setBlendAdditive(false);
723             return true;
724         }
725         return false;
726     }
727 });
728 
729 /**
730  * Create an explosion particle system
731  * @deprecated since v3.0 please use new cc.ParticleExplosion() instead.
732  * @return {cc.ParticleExplosion}
733  */
734 cc.ParticleExplosion.create = function () {
735     return new cc.ParticleExplosion();
736 };
737 
738 /**
739  * A smoke particle system
740  * @class
741  * @extends cc.ParticleSystem
742  *
743  * @example
744  * var emitter = new cc.ParticleSmoke();
745  */
746 cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{
747 
748     /**
749      * <p>The cc.ParticleSmoke's constructor. <br/>
750      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSmoke()".<br/>
751      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
752      */
753     ctor:function () {
754         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 200 : 100);
755     },
756 
757     /**
758      * initialize a smoke particle system with number Of Particles
759      * @param {Number} numberOfParticles
760      * @return {Boolean}
761      */
762     initWithTotalParticles:function (numberOfParticles) {
763         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
764             // duration
765             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
766 
767             // Emitter mode: Gravity Mode
768             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
769 
770             // Gravity Mode: gravity
771             this.setGravity(cc.p(0, 0));
772 
773             // Gravity Mode: radial acceleration
774             this.setRadialAccel(0);
775             this.setRadialAccelVar(0);
776 
777             // Gravity Mode: speed of particles
778             this.setSpeed(25);
779             this.setSpeedVar(10);
780 
781             // angle
782             this.setAngle(90);
783             this.setAngleVar(5);
784 
785             // emitter position
786             var winSize = cc.director.getWinSize();
787             this.setPosition(winSize.width / 2, 0);
788             this.setPosVar(cc.p(20, 0));
789 
790             // life of particles
791             this.setLife(4);
792             this.setLifeVar(1);
793 
794             // size, in pixels
795             this.setStartSize(60.0);
796             this.setStartSizeVar(10.0);
797             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
798 
799             // emits per frame
800             this.setEmissionRate(this.getTotalParticles() / this.getLife());
801 
802             // color of particles
803             this.setStartColor(cc.color(204, 204, 204, 255));
804             this.setStartColorVar(cc.color(5, 5, 5, 0));
805             this.setEndColor(cc.color(0, 0, 0, 255));
806             this.setEndColorVar(cc.color(0, 0, 0, 0));
807 
808             // additive
809             this.setBlendAdditive(false);
810             return true;
811         }
812         return false;
813     }
814 });
815 
816 /**
817  * Create a smoke particle system
818  * @deprecated since v3.0 please use new cc.ParticleSmoke() instead.
819  * @return {cc.ParticleSmoke}
820  */
821 cc.ParticleSmoke.create = function () {
822     return new cc.ParticleSmoke();
823 };
824 
825 /**
826  * A snow particle system
827  * @class
828  * @extends cc.ParticleSystem
829  *
830  * @example
831  * var emitter = new cc.ParticleSnow();
832  */
833 cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{
834 
835     /**
836      * <p>The cc.ParticleSnow's constructor. <br/>
837      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSnow()".<br/>
838      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
839      */
840     ctor:function () {
841         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 700 : 250);
842     },
843 
844     /**
845      * initialize a snow particle system with number Of Particles
846      * @param {Number} numberOfParticles
847      * @return {Boolean}
848      */
849     initWithTotalParticles:function (numberOfParticles) {
850         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
851             // duration
852             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
853 
854             // set gravity mode.
855             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
856 
857             // Gravity Mode: gravity
858             this.setGravity(cc.p(0, -1));
859 
860             // Gravity Mode: speed of particles
861             this.setSpeed(5);
862             this.setSpeedVar(1);
863 
864             // Gravity Mode: radial
865             this.setRadialAccel(0);
866             this.setRadialAccelVar(1);
867 
868             // Gravity mode: tangential
869             this.setTangentialAccel(0);
870             this.setTangentialAccelVar(1);
871 
872             // emitter position
873             var winSize = cc.director.getWinSize();
874             this.setPosition(winSize.width / 2, winSize.height + 10);
875             this.setPosVar(cc.p(winSize.width / 2, 0));
876 
877             // angle
878             this.setAngle(-90);
879             this.setAngleVar(5);
880 
881             // life of particles
882             this.setLife(45);
883             this.setLifeVar(15);
884 
885             // size, in pixels
886             this.setStartSize(10.0);
887             this.setStartSizeVar(5.0);
888             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
889 
890             // emits per second
891             this.setEmissionRate(10);
892 
893             // color of particles
894             this.setStartColor(cc.color(255, 255, 255, 255));
895             this.setStartColorVar(cc.color(0, 0, 0, 0));
896             this.setEndColor(cc.color(255, 255, 255, 0));
897             this.setEndColorVar(cc.color(0, 0, 0, 0));
898 
899             // additive
900             this.setBlendAdditive(false);
901             return true;
902         }
903         return false;
904     }
905 });
906 
907 /**
908  * Create a snow particle system
909  * @deprecated since v3.0 please use new cc.ParticleSnow() instead.
910  * @return {cc.ParticleSnow}
911  */
912 cc.ParticleSnow.create = function () {
913     return new cc.ParticleSnow();
914 };
915 
916 //! @brief A rain particle system
917 /**
918  * A rain particle system
919  * @class
920  * @extends cc.ParticleSystem
921  *
922  * @example
923  * var emitter = new cc.ParticleRain();
924  */
925 cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{
926 
927     /**
928      * <p>The cc.ParticleRain's constructor. <br/>
929      * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleRain()".<br/>
930      * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
931      */
932     ctor:function () {
933         cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc.game.RENDER_TYPE_WEBGL) ? 1000 : 300);
934     },
935 
936     /**
937      * initialize a rain particle system with number Of Particles
938      * @param {Number} numberOfParticles
939      * @return {Boolean}
940      */
941     initWithTotalParticles:function (numberOfParticles) {
942         if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
943             // duration
944             this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
945 
946             this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
947 
948             // Gravity Mode: gravity
949             this.setGravity(cc.p(10, -10));
950 
951             // Gravity Mode: radial
952             this.setRadialAccel(0);
953             this.setRadialAccelVar(1);
954 
955             // Gravity Mode: tangential
956             this.setTangentialAccel(0);
957             this.setTangentialAccelVar(1);
958 
959             // Gravity Mode: speed of particles
960             this.setSpeed(130);
961             this.setSpeedVar(30);
962 
963             // angle
964             this.setAngle(-90);
965             this.setAngleVar(5);
966 
967 
968             // emitter position
969             var winSize = cc.director.getWinSize();
970             this.setPosition(winSize.width / 2, winSize.height);
971             this.setPosVar(cc.p(winSize.width / 2, 0));
972 
973             // life of particles
974             this.setLife(4.5);
975             this.setLifeVar(0);
976 
977             // size, in pixels
978             this.setStartSize(4.0);
979             this.setStartSizeVar(2.0);
980             this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
981 
982             // emits per second
983             this.setEmissionRate(20);
984 
985             // color of particles
986             this.setStartColor(cc.color(179, 204, 255, 255));
987             this.setStartColorVar(cc.color(0, 0, 0, 0));
988             this.setEndColor(cc.color(179, 204, 255, 128));
989             this.setEndColorVar(cc.color(0, 0, 0, 0));
990 
991             // additive
992             this.setBlendAdditive(false);
993             return true;
994         }
995         return false;
996     }
997 });
998 
999 /**
1000  * Create a rain particle system
1001  * @deprecated since v3.0 please use cc.ParticleRain() instead.
1002  * @return {cc.ParticleRain}
1003  */
1004 cc.ParticleRain.create = function () {
1005     return new cc.ParticleRain();
1006 };
1007