1 /****************************************************************************
  2  Copyright (c) 2010-2012 cocos2d-x.org
  3  Copyright (c) 2008-2010 Ricardo Quesada
  4  Copyright (c) 2011      Zynga 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.ParticleSystemQuad
 31  *
 32  * @example
 33  * var emitter = cc.ParticleFire.create();
 34  */
 35 cc.ParticleFire = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleFire# */{
 36     /**
 37      * initialize a fire particle system
 38      * @return {Boolean}
 39      */
 40     init:function () {
 41         return this.initWithTotalParticles(150);
 42         //return this.initWithTotalParticles(250);
 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 (this._super(numberOfParticles)) {
 52             // duration
 53             this._duration = cc.PARTICLE_DURATION_INFINITY;
 54 
 55             // Gravity Mode
 56             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
 57 
 58             // Gravity Mode: gravity
 59             this.modeA.gravity = cc.p(0, 0);
 60 
 61             // Gravity Mode: radial acceleration
 62             this.modeA.radialAccel = 0;
 63             this.modeA.radialAccelVar = 0;
 64 
 65             // Gravity Mode: speed of particles
 66             this.modeA.speed = 60;
 67             this.modeA.speedVar = 20;
 68 
 69             // starting angle
 70             this._angle = 90;
 71             this._angleVar = 10;
 72 
 73             // emitter position
 74             var winSize = cc.Director.getInstance().getWinSize();
 75             this.setPosition(cc.p(winSize.width / 2, 60));
 76             this._posVar = cc.p(40, 20);
 77 
 78             // life of particles
 79             this._life = 3;
 80             this._lifeVar = 0.25;
 81 
 82 
 83             // size, in pixels
 84             this._startSize = 54.0;
 85             this._startSizeVar = 10.0;
 86             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
 87 
 88             // emits per frame
 89             this._emissionRate = this._totalParticles / this._life;
 90 
 91             // color of particles
 92             this._startColor.r = 0.76;
 93             this._startColor.g = 0.25;
 94             this._startColor.b = 0.12;
 95             this._startColor.a = 1.0;
 96             this._startColorVar.r = 0.0;
 97             this._startColorVar.g = 0.0;
 98             this._startColorVar.b = 0.0;
 99             this._startColorVar.a = 0.0;
100             this._endColor.r = 0.0;
101             this._endColor.g = 0.0;
102             this._endColor.b = 0.0;
103             this._endColor.a = 1.0;
104             this._endColorVar.r = 0.0;
105             this._endColorVar.g = 0.0;
106             this._endColorVar.b = 0.0;
107             this._endColorVar.a = 0.0;
108 
109             // additive
110             this.setBlendAdditive(true);
111             return true;
112         }
113         return false;
114     }
115 });
116 
117 /**
118  * Create a fire particle system
119  * @return {cc.ParticleFire}
120  *
121  * @example
122  * var emitter = cc.ParticleFire.create();
123  */
124 cc.ParticleFire.create = function () {
125     var ret = new cc.ParticleFire();
126     if (ret.init()) {
127         return ret;
128     }
129     return null;
130 };
131 
132 /**
133  * A fireworks particle system
134  * @class
135  * @extends cc.ParticleSystemQuad
136  *
137  * @example
138  * var emitter = cc.ParticleFireworks.create();
139  */
140 cc.ParticleFireworks = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleFireworks# */{
141     /**
142      * initialize a fireworks particle system
143      * @return {Boolean}
144      */
145     init:function () {
146         //return this.initWithTotalParticles(1500);
147         return this.initWithTotalParticles(150);
148     },
149 
150     /**
151      * initialize a fireworks particle system with number Of Particles
152      * @param {Number} numberOfParticles
153      * @return {Boolean}
154      */
155     initWithTotalParticles:function (numberOfParticles) {
156         if (this._super(numberOfParticles)) {
157             // duration
158             this._duration = cc.PARTICLE_DURATION_INFINITY;
159 
160             // Gravity Mode
161             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
162 
163             // Gravity Mode: gravity
164             this.modeA.gravity = cc.p(0, -90);
165 
166             // Gravity Mode:  radial
167             this.modeA.radialAccel = 0;
168             this.modeA.radialAccelVar = 0;
169 
170             //  Gravity Mode: speed of particles
171             this.modeA.speed = 180;
172             this.modeA.speedVar = 50;
173 
174             // emitter position
175             var winSize = cc.Director.getInstance().getWinSize();
176             this.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
177 
178             // angle
179             this._angle = 90;
180             this._angleVar = 20;
181 
182             // life of particles
183             this._life = 3.5;
184             this._lifeVar = 1;
185 
186             // emits per frame
187             this._emissionRate = this._totalParticles / this._life;
188 
189             // color of particles
190             this._startColor.r = 0.5;
191             this._startColor.g = 0.5;
192             this._startColor.b = 0.5;
193             this._startColor.a = 1.0;
194             this._startColorVar.r = 0.5;
195             this._startColorVar.g = 0.5;
196             this._startColorVar.b = 0.5;
197             this._startColorVar.a = 0.1;
198             this._endColor.r = 0.1;
199             this._endColor.g = 0.1;
200             this._endColor.b = 0.1;
201             this._endColor.a = 0.2;
202             this._endColorVar.r = 0.1;
203             this._endColorVar.g = 0.1;
204             this._endColorVar.b = 0.1;
205             this._endColorVar.a = 0.2;
206 
207             // size, in pixels
208             this._startSize = 8.0;
209             this._startSizeVar = 2.0;
210             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
211 
212             // additive
213             this.setBlendAdditive(false);
214             return true;
215         }
216         return false;
217     }
218 });
219 
220 /**
221  * Create a fireworks particle system
222  * @return {cc.ParticleFireworks}
223  *
224  * @example
225  * var emitter = cc.ParticleFireworks.create();
226  */
227 cc.ParticleFireworks.create = function () {
228     var ret = new cc.ParticleFireworks();
229     if (ret.init()) {
230         return ret;
231     }
232     return null;
233 };
234 
235 /**
236  * A sun particle system
237  * @class
238  * @extends cc.ParticleSystemQuad
239  *
240  * @example
241  * var emitter = cc.ParticleSun.create();
242  */
243 cc.ParticleSun = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleSun# */{
244     /**
245      * initialize a sun particle system
246      * @return {Boolean}
247      */
248     init:function () {
249         //return this.initWithTotalParticles(350);
250         return this.initWithTotalParticles(150);
251     },
252 
253     /**
254      * initialize a sun particle system with number Of Particles
255      * @param {Number} numberOfParticles
256      * @return {Boolean}
257      */
258     initWithTotalParticles:function (numberOfParticles) {
259         if (this._super(numberOfParticles)) {
260             // additive
261             this.setBlendAdditive(true);
262 
263             // duration
264             this._duration = cc.PARTICLE_DURATION_INFINITY;
265 
266             // Gravity Mode
267             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
268 
269             // Gravity Mode: gravity
270             this.modeA.gravity = cc.p(0, 0);
271 
272             // Gravity mode: radial acceleration
273             this.modeA.radialAccel = 0;
274             this.modeA.radialAccelVar = 0;
275 
276             // Gravity mode: speed of particles
277             this.modeA.speed = 20;
278             this.modeA.speedVar = 5;
279 
280 
281             // angle
282             this._angle = 90;
283             this._angleVar = 360;
284 
285             // emitter position
286             var winSize = cc.Director.getInstance().getWinSize();
287             this.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
288             this._posVar = cc.PointZero();
289 
290             // life of particles
291             this._life = 1;
292             this._lifeVar = 0.5;
293 
294             // size, in pixels
295             this._startSize = 30.0;
296             this._startSizeVar = 10.0;
297             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
298 
299             // emits per seconds
300             this._emissionRate = this._totalParticles / this._life;
301 
302             // color of particles
303             this._startColor.r = 0.76;
304             this._startColor.g = 0.25;
305             this._startColor.b = 0.12;
306             this._startColor.a = 1.0;
307             this._startColorVar.r = 0.0;
308             this._startColorVar.g = 0.0;
309             this._startColorVar.b = 0.0;
310             this._startColorVar.a = 0.0;
311             this._endColor.r = 0.0;
312             this._endColor.g = 0.0;
313             this._endColor.b = 0.0;
314             this._endColor.a = 1.0;
315             this._endColorVar.r = 0.0;
316             this._endColorVar.g = 0.0;
317             this._endColorVar.b = 0.0;
318             this._endColorVar.a = 0.0;
319 
320             return true;
321         }
322         return false;
323     }
324 });
325 
326 /**
327  * Create a sun particle system
328  * @return {cc.ParticleSun}
329  *
330  * @example
331  * var emitter = cc.ParticleSun.create();
332  */
333 cc.ParticleSun.create = function () {
334     var ret = new cc.ParticleSun();
335     if (ret.init()) {
336         return ret;
337     }
338     return null;
339 };
340 
341 //! @brief A  particle system
342 /**
343  * A galaxy particle system
344  * @class
345  * @extends cc.ParticleSystemQuad
346  *
347  * @example
348  * var emitter = cc.ParticleGalaxy.create();
349  */
350 cc.ParticleGalaxy = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleGalaxy# */{
351     /**
352      * initialize a galaxy particle system
353      * @return {Boolean}
354      */
355     init:function () {
356         //return this.initWithTotalParticles(200);
357         return this.initWithTotalParticles(100);
358     },
359 
360     /**
361      * initialize a galaxy particle system with number Of Particles
362      * @param {Number} numberOfParticles
363      * @return {Boolean}
364      */
365     initWithTotalParticles:function (numberOfParticles) {
366         if (this._super(numberOfParticles)) {
367             // duration
368             this._duration = cc.PARTICLE_DURATION_INFINITY;
369 
370             // Gravity Mode
371             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
372 
373             // Gravity Mode: gravity
374             this.modeA.gravity = cc.p(0, 0);
375 
376             // Gravity Mode: speed of particles
377             this.modeA.speed = 60;
378             this.modeA.speedVar = 10;
379 
380             // Gravity Mode: radial
381             this.modeA.radialAccel = -80;
382             this.modeA.radialAccelVar = 0;
383 
384             // Gravity Mode: tagential
385             this.modeA.tangentialAccel = 80;
386             this.modeA.tangentialAccelVar = 0;
387 
388             // angle
389             this._angle = 90;
390             this._angleVar = 360;
391 
392             // emitter position
393             var winSize = cc.Director.getInstance().getWinSize();
394             this.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
395             this._posVar = cc.PointZero();
396 
397             // life of particles
398             this._life = 4;
399             this._lifeVar = 1;
400 
401             // size, in pixels
402             this._startSize = 37.0;
403             this._startSizeVar = 10.0;
404             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
405 
406             // emits per second
407             this._emissionRate = this._totalParticles / this._life;
408 
409             // color of particles
410             this._startColor.r = 0.12;
411             this._startColor.g = 0.25;
412             this._startColor.b = 0.76;
413             this._startColor.a = 1.0;
414             this._startColorVar.r = 0.0;
415             this._startColorVar.g = 0.0;
416             this._startColorVar.b = 0.0;
417             this._startColorVar.a = 0.0;
418             this._endColor.r = 0.0;
419             this._endColor.g = 0.0;
420             this._endColor.b = 0.0;
421             this._endColor.a = 1.0;
422             this._endColorVar.r = 0.0;
423             this._endColorVar.g = 0.0;
424             this._endColorVar.b = 0.0;
425             this._endColorVar.a = 0.0;
426 
427             // additive
428             this.setBlendAdditive(true);
429             return true;
430         }
431         return false;
432     }
433 });
434 /**
435  * Create a galaxy particle system
436  * @return {cc.ParticleGalaxy}
437  *
438  * @example
439  * var emitter = cc.ParticleGalaxy.create();
440  */
441 cc.ParticleGalaxy.create = function () {
442     var ret = new cc.ParticleGalaxy();
443     if (ret.init()) {
444         return ret;
445     }
446     return null;
447 };
448 
449 /**
450  * A flower particle system
451  * @class
452  * @extends cc.ParticleSystemQuad
453  *
454  * @example
455  * var emitter = cc.ParticleFlower.create();
456  */
457 cc.ParticleFlower = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleFlower# */{
458     /**
459      * initialize a flower particle system
460      * @return {Boolean}
461      */
462     init:function () {
463         //return this.initWithTotalParticles(250);
464         return this.initWithTotalParticles(100);
465     },
466 
467     /**
468      * initialize a flower particle system with number Of Particles
469      * @param {Number} numberOfParticles
470      * @return {Boolean}
471      */
472     initWithTotalParticles:function (numberOfParticles) {
473         if (this._super(numberOfParticles)) {
474             // duration
475             this._duration = cc.PARTICLE_DURATION_INFINITY;
476 
477             // Gravity Mode
478             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
479 
480             // Gravity Mode: gravity
481             this.modeA.gravity = cc.p(0, 0);
482 
483             // Gravity Mode: speed of particles
484             this.modeA.speed = 80;
485             this.modeA.speedVar = 10;
486 
487             // Gravity Mode: radial
488             this.modeA.radialAccel = -60;
489             this.modeA.radialAccelVar = 0;
490 
491             // Gravity Mode: tagential
492             this.modeA.tangentialAccel = 15;
493             this.modeA.tangentialAccelVar = 0;
494 
495             // angle
496             this._angle = 90;
497             this._angleVar = 360;
498 
499             // emitter position
500             var winSize = cc.Director.getInstance().getWinSize();
501             this.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
502             this._posVar = cc.PointZero();
503 
504             // life of particles
505             this._life = 4;
506             this._lifeVar = 1;
507 
508             // size, in pixels
509             this._startSize = 30.0;
510             this._startSizeVar = 10.0;
511             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
512 
513             // emits per second
514             this._emissionRate = this._totalParticles / this._life;
515 
516             // color of particles
517             this._startColor.r = 0.50;
518             this._startColor.g = 0.50;
519             this._startColor.b = 0.50;
520             this._startColor.a = 1.0;
521             this._startColorVar.r = 0.5;
522             this._startColorVar.g = 0.5;
523             this._startColorVar.b = 0.5;
524             this._startColorVar.a = 0.5;
525             this._endColor.r = 0.0;
526             this._endColor.g = 0.0;
527             this._endColor.b = 0.0;
528             this._endColor.a = 1.0;
529             this._endColorVar.r = 0.0;
530             this._endColorVar.g = 0.0;
531             this._endColorVar.b = 0.0;
532             this._endColorVar.a = 0.0;
533 
534             // additive
535             this.setBlendAdditive(true);
536             return true;
537         }
538         return false;
539     }
540 });
541 
542 /**
543  * Create a flower particle system
544  * @return {cc.ParticleFlower}
545  *
546  * @example
547  * var emitter = cc.ParticleFlower.create();
548  */
549 cc.ParticleFlower.create = function () {
550     var ret = new cc.ParticleFlower();
551     if (ret.init()) {
552         return ret;
553     }
554     return null;
555 };
556 
557 //! @brief A meteor particle system
558 /**
559  * A meteor particle system
560  * @class
561  * @extends cc.ParticleSystemQuad
562  *
563  * @example
564  * var emitter = cc.ParticleMeteor.create();
565  */
566 cc.ParticleMeteor = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleMeteor# */{
567     /**
568      * initialize a meteor particle system
569      * @return {Boolean}
570      */
571     init:function () {
572         //return this.initWithTotalParticles(150);
573         return this.initWithTotalParticles(100);
574     },
575 
576     /**
577      * initialize a meteor particle system with number Of Particles
578      * @param {Number} numberOfParticles
579      * @return {Boolean}
580      */
581     initWithTotalParticles:function (numberOfParticles) {
582         if (this._super(numberOfParticles)) {
583             // duration
584             this._duration = cc.PARTICLE_DURATION_INFINITY;
585 
586             // Gravity Mode
587             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
588 
589             // Gravity Mode: gravity
590             this.modeA.gravity = cc.p(-200, 200);
591 
592             // Gravity Mode: speed of particles
593             this.modeA.speed = 15;
594             this.modeA.speedVar = 5;
595 
596             // Gravity Mode: radial
597             this.modeA.radialAccel = 0;
598             this.modeA.radialAccelVar = 0;
599 
600             // Gravity Mode: tagential
601             this.modeA.tangentialAccel = 0;
602             this.modeA.tangentialAccelVar = 0;
603 
604             // angle
605             this._angle = 90;
606             this._angleVar = 360;
607 
608             // emitter position
609             var winSize = cc.Director.getInstance().getWinSize();
610             this.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
611             this._posVar = cc.PointZero();
612 
613             // life of particles
614             this._life = 2;
615             this._lifeVar = 1;
616 
617             // size, in pixels
618             this._startSize = 60.0;
619             this._startSizeVar = 10.0;
620             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
621 
622             // emits per second
623             this._emissionRate = this._totalParticles / this._life;
624 
625             // color of particles
626             this._startColor.r = 0.2;
627             this._startColor.g = 0.4;
628             this._startColor.b = 0.7;
629             this._startColor.a = 1.0;
630             this._startColorVar.r = 0.0;
631             this._startColorVar.g = 0.0;
632             this._startColorVar.b = 0.2;
633             this._startColorVar.a = 0.1;
634             this._endColor.r = 0.0;
635             this._endColor.g = 0.0;
636             this._endColor.b = 0.0;
637             this._endColor.a = 1.0;
638             this._endColorVar.r = 0.0;
639             this._endColorVar.g = 0.0;
640             this._endColorVar.b = 0.0;
641             this._endColorVar.a = 0.0;
642 
643             // additive
644             this.setBlendAdditive(true);
645             return true;
646         }
647         return false;
648     }
649 });
650 
651 /**
652  * Create a meteor particle system
653  * @return {cc.ParticleFireworks}
654  *
655  * @example
656  * var emitter = cc.ParticleMeteor.create();
657  */
658 cc.ParticleMeteor.create = function () {
659     var ret = new cc.ParticleMeteor();
660     if (ret.init()) {
661         return ret;
662     }
663     return null;
664 };
665 
666 /**
667  * A spiral particle system
668  * @class
669  * @extends cc.ParticleSystemQuad
670  *
671  * @example
672  * var emitter = cc.ParticleSpiral.create();
673  */
674 cc.ParticleSpiral = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleSpiral# */{
675     /**
676      * initialize a spiral particle system
677      * @return {Boolean}
678      */
679     init:function () {
680         //return this.initWithTotalParticles(500);
681         return this.initWithTotalParticles(100);
682     },
683 
684     /**
685      * initialize a spiral particle system with number Of Particles
686      * @param {Number} numberOfParticles
687      * @return {Boolean}
688      */
689     initWithTotalParticles:function (numberOfParticles) {
690         if (this._super(numberOfParticles)) {
691             // duration
692             this._duration = cc.PARTICLE_DURATION_INFINITY;
693 
694             // Gravity Mode
695             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
696 
697             // Gravity Mode: gravity
698             this.modeA.gravity = cc.p(0, 0);
699 
700             // Gravity Mode: speed of particles
701             this.modeA.speed = 150;
702             this.modeA.speedVar = 0;
703 
704             // Gravity Mode: radial
705             this.modeA.radialAccel = -380;
706             this.modeA.radialAccelVar = 0;
707 
708             // Gravity Mode: tagential
709             this.modeA.tangentialAccel = 45;
710             this.modeA.tangentialAccelVar = 0;
711 
712             // angle
713             this._angle = 90;
714             this._angleVar = 0;
715 
716             // emitter position
717             var winSize = cc.Director.getInstance().getWinSize();
718             this.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
719             this._posVar = cc.PointZero();
720 
721             // life of particles
722             this._life = 12;
723             this._lifeVar = 0;
724 
725             // size, in pixels
726             this._startSize = 20.0;
727             this._startSizeVar = 0.0;
728             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
729 
730             // emits per second
731             this._emissionRate = this._totalParticles / this._life;
732 
733             // color of particles
734             this._startColor.r = 0.5;
735             this._startColor.g = 0.5;
736             this._startColor.b = 0.5;
737             this._startColor.a = 1.0;
738             this._startColorVar.r = 0.5;
739             this._startColorVar.g = 0.5;
740             this._startColorVar.b = 0.5;
741             this._startColorVar.a = 0.0;
742             this._endColor.r = 0.5;
743             this._endColor.g = 0.5;
744             this._endColor.b = 0.5;
745             this._endColor.a = 1.0;
746             this._endColorVar.r = 0.5;
747             this._endColorVar.g = 0.5;
748             this._endColorVar.b = 0.5;
749             this._endColorVar.a = 0.0;
750 
751             // additive
752             this.setBlendAdditive(false);
753             return true;
754         }
755         return false;
756     }
757 });
758 
759 /**
760  * Create a spiral particle system
761  * @return {cc.ParticleSpiral}
762  *
763  * @example
764  * var emitter = cc.ParticleSpiral.create();
765  */
766 cc.ParticleSpiral.create = function () {
767     var ret = new cc.ParticleSpiral();
768     if (ret.init()) {
769         return ret;
770     }
771     return null;
772 };
773 
774 /**
775  * An explosion particle system
776  * @class
777  * @extends cc.ParticleSystemQuad
778  *
779  * @example
780  * var emitter = cc.ParticleExplosion.create();
781  */
782 cc.ParticleExplosion = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleExplosion# */{
783     /**
784      * initialize an explosion particle system
785      * @return {Boolean}
786      */
787     init:function () {
788         //return this.initWithTotalParticles(700);
789         return this.initWithTotalParticles(300);
790     },
791 
792     /**
793      * initialize an explosion particle system with number Of Particles
794      * @param {Number} numberOfParticles
795      * @return {Boolean}
796      */
797     initWithTotalParticles:function (numberOfParticles) {
798         if (this._super(numberOfParticles)) {
799             // duration
800             this._duration = 0.1;
801 
802             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
803 
804             // Gravity Mode: gravity
805             this.modeA.gravity = cc.p(0, 0);
806 
807             // Gravity Mode: speed of particles
808             this.modeA.speed = 70;
809             this.modeA.speedVar = 40;
810 
811             // Gravity Mode: radial
812             this.modeA.radialAccel = 0;
813             this.modeA.radialAccelVar = 0;
814 
815             // Gravity Mode: tagential
816             this.modeA.tangentialAccel = 0;
817             this.modeA.tangentialAccelVar = 0;
818 
819             // angle
820             this._angle = 90;
821             this._angleVar = 360;
822 
823             // emitter position
824             var winSize = cc.Director.getInstance().getWinSize();
825             this.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
826             this._posVar = cc.PointZero();
827 
828             // life of particles
829             this._life = 5.0;
830             this._lifeVar = 2;
831 
832             // size, in pixels
833             this._startSize = 15.0;
834             this._startSizeVar = 10.0;
835             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
836 
837             // emits per second
838             this._emissionRate = this._totalParticles / this._duration;
839 
840             // color of particles
841             this._startColor.r = 0.7;
842             this._startColor.g = 0.1;
843             this._startColor.b = 0.2;
844             this._startColor.a = 1.0;
845             this._startColorVar.r = 0.5;
846             this._startColorVar.g = 0.5;
847             this._startColorVar.b = 0.5;
848             this._startColorVar.a = 0.0;
849             this._endColor.r = 0.5;
850             this._endColor.g = 0.5;
851             this._endColor.b = 0.5;
852             this._endColor.a = 0.0;
853             this._endColorVar.r = 0.5;
854             this._endColorVar.g = 0.5;
855             this._endColorVar.b = 0.5;
856             this._endColorVar.a = 0.0;
857 
858             // additive
859             this.setBlendAdditive(false);
860             return true;
861         }
862         return false;
863     }
864 });
865 
866 /**
867  * Create an explosion particle system
868  * @return {cc.ParticleExplosion}
869  *
870  * @example
871  * var emitter = cc.ParticleExplosion.create();
872  */
873 cc.ParticleExplosion.create = function () {
874     var ret = new cc.ParticleExplosion();
875     if (ret.init()) {
876         return ret;
877     }
878     return null;
879 };
880 
881 /**
882  * A smoke particle system
883  * @class
884  * @extends cc.ParticleSystemQuad
885  *
886  * @example
887  * var emitter = cc.ParticleSmoke.create();
888  */
889 cc.ParticleSmoke = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleSmoke# */{
890     /**
891      * initialize a smoke particle system
892      * @return {Boolean}
893      */
894     init:function () {
895         //return this.initWithTotalParticles(200);
896         return this.initWithTotalParticles(100);
897     },
898 
899     /**
900      * initialize a smoke particle system with number Of Particles
901      * @param {Number} numberOfParticles
902      * @return {Boolean}
903      */
904     initWithTotalParticles:function (numberOfParticles) {
905         if (this._super(numberOfParticles)) {
906             // duration
907             this._duration = cc.PARTICLE_DURATION_INFINITY;
908 
909             // Emitter mode: Gravity Mode
910             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
911 
912             // Gravity Mode: gravity
913             this.modeA.gravity = cc.p(0, 0);
914 
915             // Gravity Mode: radial acceleration
916             this.modeA.radialAccel = 0;
917             this.modeA.radialAccelVar = 0;
918 
919             // Gravity Mode: speed of particles
920             this.modeA.speed = 25;
921             this.modeA.speedVar = 10;
922 
923             // angle
924             this._angle = 90;
925             this._angleVar = 5;
926 
927             // emitter position
928             var winSize = cc.Director.getInstance().getWinSize();
929             this.setPosition(cc.p(winSize.width / 2, 0));
930             this._posVar = cc.p(20, 0);
931 
932             // life of particles
933             this._life = 4;
934             this._lifeVar = 1;
935 
936             // size, in pixels
937             this._startSize = 60.0;
938             this._startSizeVar = 10.0;
939             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
940 
941             // emits per frame
942             this._emissionRate = this._totalParticles / this._life;
943 
944             // color of particles
945             this._startColor.r = 0.8;
946             this._startColor.g = 0.8;
947             this._startColor.b = 0.8;
948             this._startColor.a = 1.0;
949             this._startColorVar.r = 0.02;
950             this._startColorVar.g = 0.02;
951             this._startColorVar.b = 0.02;
952             this._startColorVar.a = 0.0;
953             this._endColor.r = 0.0;
954             this._endColor.g = 0.0;
955             this._endColor.b = 0.0;
956             this._endColor.a = 1.0;
957             this._endColorVar.r = 0.0;
958             this._endColorVar.g = 0.0;
959             this._endColorVar.b = 0.0;
960             this._endColorVar.a = 0.0;
961 
962             // additive
963             this.setBlendAdditive(false);
964             return true;
965         }
966         return false;
967     }
968 });
969 
970 /**
971  * Create a smoke particle system
972  * @return {cc.ParticleFireworks}
973  *
974  * @example
975  * var emitter = cc.ParticleFireworks.create();
976  */
977 cc.ParticleSmoke.create = function () {
978     var ret = new cc.ParticleSmoke();
979     if (ret.init()) {
980         return ret;
981     }
982     return null;
983 };
984 
985 /**
986  * A snow particle system
987  * @class
988  * @extends cc.ParticleSystemQuad
989  *
990  * @example
991  * var emitter = cc.ParticleSnow.create();
992  */
993 cc.ParticleSnow = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleSnow# */{
994     /**
995      * initialize a snow particle system
996      * @return {Boolean}
997      */
998     init:function () {
999         return this.initWithTotalParticles(250);
1000         //return this.initWithTotalParticles(700);
1001     },
1002 
1003     /**
1004      * initialize a snow particle system with number Of Particles
1005      * @param {Number} numberOfParticles
1006      * @return {Boolean}
1007      */
1008     initWithTotalParticles:function (numberOfParticles) {
1009         if (this._super(numberOfParticles)) {
1010             // duration
1011             this._duration = cc.PARTICLE_DURATION_INFINITY;
1012 
1013             // set gravity mode.
1014             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
1015 
1016             // Gravity Mode: gravity
1017             this.modeA.gravity = cc.p(0, -1);
1018 
1019             // Gravity Mode: speed of particles
1020             this.modeA.speed = 5;
1021             this.modeA.speedVar = 1;
1022 
1023             // Gravity Mode: radial
1024             this.modeA.radialAccel = 0;
1025             this.modeA.radialAccelVar = 1;
1026 
1027             // Gravity mode: tagential
1028             this.modeA.tangentialAccel = 0;
1029             this.modeA.tangentialAccelVar = 1;
1030 
1031             // emitter position
1032             var winSize = cc.Director.getInstance().getWinSize();
1033             this.setPosition(cc.p(winSize.width / 2, winSize.height + 10));
1034             this._posVar = cc.p(winSize.width / 2, 0);
1035 
1036             // angle
1037             this._angle = -90;
1038             this._angleVar = 5;
1039 
1040             // life of particles
1041             this._life = 45;
1042             this._lifeVar = 15;
1043 
1044             // size, in pixels
1045             this._startSize = 10.0;
1046             this._startSizeVar = 5.0;
1047             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
1048 
1049             // emits per second
1050             this._emissionRate = 10;
1051 
1052             // color of particles
1053             this._startColor.r = 1.0;
1054             this._startColor.g = 1.0;
1055             this._startColor.b = 1.0;
1056             this._startColor.a = 1.0;
1057             this._startColorVar.r = 0.0;
1058             this._startColorVar.g = 0.0;
1059             this._startColorVar.b = 0.0;
1060             this._startColorVar.a = 0.0;
1061             this._endColor.r = 1.0;
1062             this._endColor.g = 1.0;
1063             this._endColor.b = 1.0;
1064             this._endColor.a = 0.0;
1065             this._endColorVar.r = 0.0;
1066             this._endColorVar.g = 0.0;
1067             this._endColorVar.b = 0.0;
1068             this._endColorVar.a = 0.0;
1069 
1070             // additive
1071             this.setBlendAdditive(false);
1072             return true;
1073         }
1074         return false;
1075     }
1076 });
1077 
1078 /**
1079  * Create a snow particle system
1080  * @return {cc.ParticleSnow}
1081  *
1082  * @example
1083  * var emitter = cc.ParticleSnow.create();
1084  */
1085 cc.ParticleSnow.create = function () {
1086     var ret = new cc.ParticleSnow();
1087     if (ret.init()) {
1088         return ret;
1089     }
1090     return null;
1091 };
1092 
1093 //! @brief A rain particle system
1094 /**
1095  * A rain particle system
1096  * @class
1097  * @extends cc.ParticleSystemQuad
1098  *
1099  * @example
1100  * var emitter = cc.ParticleRain.create();
1101  */
1102 cc.ParticleRain = cc.ParticleSystemQuad.extend(/** @lends cc.ParticleRain# */{
1103     /**
1104      * initialize a rain particle system
1105      * @return {Boolean}
1106      */
1107     init:function () {
1108         return this.initWithTotalParticles(300);
1109         //return this.initWithTotalParticles(1000);
1110     },
1111 
1112     /**
1113      * initialize a rain particle system with number Of Particles
1114      * @param {Number} numberOfParticles
1115      * @return {Boolean}
1116      */
1117     initWithTotalParticles:function (numberOfParticles) {
1118         if (this._super(numberOfParticles)) {
1119             // duration
1120             this._duration = cc.PARTICLE_DURATION_INFINITY;
1121 
1122             this._emitterMode = cc.PARTICLE_MODE_GRAVITY;
1123 
1124             // Gravity Mode: gravity
1125             this.modeA.gravity = cc.p(10, -10);
1126 
1127             // Gravity Mode: radial
1128             this.modeA.radialAccel = 0;
1129             this.modeA.radialAccelVar = 1;
1130 
1131             // Gravity Mode: tagential
1132             this.modeA.tangentialAccel = 0;
1133             this.modeA.tangentialAccelVar = 1;
1134 
1135             // Gravity Mode: speed of particles
1136             this.modeA.speed = 130;
1137             this.modeA.speedVar = 30;
1138 
1139             // angle
1140             this._angle = -90;
1141             this._angleVar = 5;
1142 
1143 
1144             // emitter position
1145             var winSize = cc.Director.getInstance().getWinSize();
1146             this.setPosition(cc.p(winSize.width / 2, winSize.height));
1147             this._posVar = cc.p(winSize.width / 2, 0);
1148 
1149             // life of particles
1150             this._life = 4.5;
1151             this._lifeVar = 0;
1152 
1153             // size, in pixels
1154             this._startSize = 4.0;
1155             this._startSizeVar = 2.0;
1156             this._endSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE;
1157 
1158             // emits per second
1159             this._emissionRate = 20;
1160 
1161             // color of particles
1162             this._startColor.r = 0.7;
1163             this._startColor.g = 0.8;
1164             this._startColor.b = 1.0;
1165             this._startColor.a = 1.0;
1166             this._startColorVar.r = 0.0;
1167             this._startColorVar.g = 0.0;
1168             this._startColorVar.b = 0.0;
1169             this._startColorVar.a = 0.0;
1170             this._endColor.r = 0.7;
1171             this._endColor.g = 0.8;
1172             this._endColor.b = 1.0;
1173             this._endColor.a = 0.5;
1174             this._endColorVar.r = 0.0;
1175             this._endColorVar.g = 0.0;
1176             this._endColorVar.b = 0.0;
1177             this._endColorVar.a = 0.0;
1178 
1179             // additive
1180             this.setBlendAdditive(false);
1181             return true;
1182         }
1183         return false;
1184     }
1185 });
1186 
1187 /**
1188  * Create a rain particle system
1189  * @return {cc.ParticleRain}
1190  *
1191  * @example
1192  * var emitter = cc.ParticleRain.create();
1193  */
1194 cc.ParticleRain.create = function () {
1195     var ret = new cc.ParticleRain();
1196     if (ret.init()) {
1197         return ret;
1198     }
1199     return null;
1200 };
1201