12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040 |
- /****************************************************************************
- Copyright (c) 2008-2010 Ricardo Quesada
- Copyright (c) 2011-2012 cocos2d-x.org
- Copyright (c) 2013-2014 Chukong Technologies Inc.
- http://www.cocos2d-x.org
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
- /**
- * A fire particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleFire();
- */
- cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{
- /**
- * <p>The cc.ParticleFire's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleFire()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 300 : 150);
- },
- /**
- * initialize a fire particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- // Gravity Mode
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(0, 0));
- // Gravity Mode: radial acceleration
- this.setRadialAccel(0);
- this.setRadialAccelVar(0);
- // Gravity Mode: speed of particles
- this.setSpeed(60);
- this.setSpeedVar(20);
- // starting angle
- this.setAngle(90);
- this.setAngleVar(10);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, 60);
- this.setPosVar(cc.p(40, 20));
- // life of particles
- this.setLife(3);
- this.setLifeVar(0.25);
- // size, in pixels
- this.setStartSize(54.0);
- this.setStartSizeVar(10.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per frame
- this.setEmissionRate(this.getTotalParticles() / this.getLife());
- // color of particles
- this.setStartColor(cc.color(194,64,31,255));
- this.setStartColorVar(cc.color(0,0,0,0));
- this.setEndColor(cc.color(0,0,0,255));
- this.setEndColorVar(cc.color(0,0,0,0));
- // additive
- this.setBlendAdditive(true);
- return true;
- }
- return false;
- }
- });
- /**
- * Create a fire particle system
- * @deprecated since v3.0 please use new cc.ParticleFire() instead
- * @return {cc.ParticleFire}
- *
- * @example
- * var emitter = cc.ParticleFire.create();
- */
- cc.ParticleFire.create = function () {
- return new cc.ParticleFire();
- };
- /**
- * A fireworks particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleFireworks();
- */
- cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks# */{
- /**
- * <p>The cc.ParticleFireworks's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleFireworks()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1500 : 150);
- },
- /**
- * initialize a fireworks particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- // Gravity Mode
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(0, -90));
- // Gravity Mode: radial
- this.setRadialAccel(0);
- this.setRadialAccelVar(0);
- // Gravity Mode: speed of particles
- this.setSpeed(180);
- this.setSpeedVar(50);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, winSize.height / 2);
- // angle
- this.setAngle(90);
- this.setAngleVar(20);
- // life of particles
- this.setLife(3.5);
- this.setLifeVar(1);
- // emits per frame
- this.setEmissionRate(this.getTotalParticles() / this.getLife());
- // color of particles
- this.setStartColor(cc.color(128,128,128,255));
- this.setStartColorVar(cc.color(128,128,128,255));
- this.setEndColor(cc.color(26,26,26,51));
- this.setEndColorVar(cc.color(26,26,26,51));
- // size, in pixels
- this.setStartSize(8.0);
- this.setStartSizeVar(2.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // additive
- this.setBlendAdditive(false);
- return true;
- }
- return false;
- }
- });
- /**
- * Create a fireworks particle system
- * @deprecated since v3.0 please use new cc.ParticleFireworks() instead.
- * @return {cc.ParticleFireworks}
- *
- * @example
- * var emitter = cc.ParticleFireworks.create();
- */
- cc.ParticleFireworks.create = function () {
- return new cc.ParticleFireworks();
- };
- /**
- * A sun particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleSun();
- */
- cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{
- /**
- * <p>The cc.ParticleSun's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSun()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 350 : 150);
- },
- /**
- * initialize a sun particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // additive
- this.setBlendAdditive(true);
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- // Gravity Mode
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(0, 0));
- // Gravity mode: radial acceleration
- this.setRadialAccel(0);
- this.setRadialAccelVar(0);
- // Gravity mode: speed of particles
- this.setSpeed(20);
- this.setSpeedVar(5);
- // angle
- this.setAngle(90);
- this.setAngleVar(360);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, winSize.height / 2);
- this.setPosVar(cc.p(0,0));
- // life of particles
- this.setLife(1);
- this.setLifeVar(0.5);
- // size, in pixels
- this.setStartSize(30.0);
- this.setStartSizeVar(10.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per seconds
- this.setEmissionRate(this.getTotalParticles() / this.getLife());
- // color of particles
- this.setStartColor(cc.color(194, 64, 31, 255));
- this.setStartColorVar(cc.color(0, 0, 0, 0));
- this.setEndColor(cc.color(0, 0, 0, 255));
- this.setEndColorVar(cc.color(0, 0, 0, 0));
- return true;
- }
- return false;
- }
- });
- /**
- * Create a sun particle system
- * @deprecated since v3.0 please use new cc.ParticleSun() instead.
- * @return {cc.ParticleSun}
- *
- * @example
- * var emitter = cc.ParticleSun.create();
- */
- cc.ParticleSun.create = function () {
- return new cc.ParticleSun();
- };
- //! @brief A particle system
- /**
- * A galaxy particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleGalaxy();
- */
- cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{
- /**
- * <p>The cc.ParticleGalaxy's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleGalaxy()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100);
- },
- /**
- * initialize a galaxy particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- // Gravity Mode
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(0, 0));
- // Gravity Mode: speed of particles
- this.setSpeed(60);
- this.setSpeedVar(10);
- // Gravity Mode: radial
- this.setRadialAccel(-80);
- this.setRadialAccelVar(0);
- // Gravity Mode: tangential
- this.setTangentialAccel(80);
- this.setTangentialAccelVar(0);
- // angle
- this.setAngle(90);
- this.setAngleVar(360);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, winSize.height / 2);
- this.setPosVar(cc.p(0,0));
- // life of particles
- this.setLife(4);
- this.setLifeVar(1);
- // size, in pixels
- this.setStartSize(37.0);
- this.setStartSizeVar(10.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per second
- this.setEmissionRate(this.getTotalParticles() / this.getLife());
- // color of particles
- this.setStartColor(cc.color(31, 64, 194, 255));
- this.setStartColorVar(cc.color(0, 0, 0, 0));
- this.setEndColor(cc.color(0, 0, 0, 255));
- this.setEndColorVar(cc.color(0, 0, 0, 0));
- // additive
- this.setBlendAdditive(true);
- return true;
- }
- return false;
- }
- });
- /**
- * Create a galaxy particle system
- * @deprecated since v3.0 please use new cc.OarticleGalaxy() instead.
- * @return {cc.ParticleGalaxy}
- *
- * @example
- * var emitter = cc.ParticleGalaxy.create();
- */
- cc.ParticleGalaxy.create = function () {
- return new cc.ParticleGalaxy();
- };
- /**
- * A flower particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleFlower();
- */
- cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{
- /**
- * <p>The cc.ParticleFlower's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleFlower()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor : function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 250 : 100);
- },
- /**
- * initialize a flower particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- // Gravity Mode
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(0, 0));
- // Gravity Mode: speed of particles
- this.setSpeed(80);
- this.setSpeedVar(10);
- // Gravity Mode: radial
- this.setRadialAccel(-60);
- this.setRadialAccelVar(0);
- // Gravity Mode: tangential
- this.setTangentialAccel(15);
- this.setTangentialAccelVar(0);
- // angle
- this.setAngle(90);
- this.setAngleVar(360);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, winSize.height / 2);
- this.setPosVar(cc.p(0,0));
- // life of particles
- this.setLife(4);
- this.setLifeVar(1);
- // size, in pixels
- this.setStartSize(30.0);
- this.setStartSizeVar(10.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per second
- this.setEmissionRate(this.getTotalParticles() / this.getLife());
- // color of particles
- this.setStartColor(cc.color(128, 128, 128, 255));
- this.setStartColorVar(cc.color(128, 128, 128, 128));
- this.setEndColor(cc.color(0, 0, 0, 255));
- this.setEndColorVar(cc.color(0, 0, 0, 0));
- // additive
- this.setBlendAdditive(true);
- return true;
- }
- return false;
- }
- });
- /**
- * Create a flower particle system
- * @deprecated since v3.0 please use new cc.ParticleFlower() instead.
- * @return {cc.ParticleFlower}
- *
- * @example
- * var emitter = cc.ParticleFlower.create();
- */
- cc.ParticleFlower.create = function () {
- return new cc.ParticleFlower();
- };
- //! @brief A meteor particle system
- /**
- * A meteor particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleMeteor();
- */
- cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{
- /**
- * <p>The cc.ParticleMeteor's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleMeteor()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 150 : 100);
- },
- /**
- * initialize a meteor particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- // Gravity Mode
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(-200, 200));
- // Gravity Mode: speed of particles
- this.setSpeed(15);
- this.setSpeedVar(5);
- // Gravity Mode: radial
- this.setRadialAccel(0);
- this.setRadialAccelVar(0);
- // Gravity Mode: tangential
- this.setTangentialAccel(0);
- this.setTangentialAccelVar(0);
- // angle
- this.setAngle(90);
- this.setAngleVar(360);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, winSize.height / 2);
- this.setPosVar(cc.p(0,0));
- // life of particles
- this.setLife(2);
- this.setLifeVar(1);
- // size, in pixels
- this.setStartSize(60.0);
- this.setStartSizeVar(10.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per second
- this.setEmissionRate(this.getTotalParticles() / this.getLife());
- // color of particles
- this.setStartColor(cc.color(51, 102, 179));
- this.setStartColorVar(cc.color(0, 0, 51, 26));
- this.setEndColor(cc.color(0, 0, 0, 255));
- this.setEndColorVar(cc.color(0, 0, 0, 0));
- // additive
- this.setBlendAdditive(true);
- return true;
- }
- return false;
- }
- });
- /**
- * Create a meteor particle system
- * @deprecated since v3.0 please use new cc.ParticleMeteor() instead.
- * @return {cc.ParticleMeteor}
- *
- * @example
- * var emitter = cc.ParticleMeteor.create();
- */
- cc.ParticleMeteor.create = function () {
- return new cc.ParticleMeteor();
- };
- /**
- * A spiral particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleSpiral();
- */
- cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{
- /**
- * <p>The cc.ParticleSpiral's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSpiral()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function() {
- cc.ParticleSystem.prototype.ctor.call(this,(cc._renderType === cc._RENDER_TYPE_WEBGL) ? 500 : 100);
- },
- /**
- * initialize a spiral particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- // Gravity Mode
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(0, 0));
- // Gravity Mode: speed of particles
- this.setSpeed(150);
- this.setSpeedVar(0);
- // Gravity Mode: radial
- this.setRadialAccel(-380);
- this.setRadialAccelVar(0);
- // Gravity Mode: tangential
- this.setTangentialAccel(45);
- this.setTangentialAccelVar(0);
- // angle
- this.setAngle(90);
- this.setAngleVar(0);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, winSize.height / 2);
- this.setPosVar(cc.p(0,0));
- // life of particles
- this.setLife(12);
- this.setLifeVar(0);
- // size, in pixels
- this.setStartSize(20.0);
- this.setStartSizeVar(0.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per second
- this.setEmissionRate(this.getTotalParticles() / this.getLife());
- // color of particles
- this.setStartColor(cc.color(128,128,128,255));
- this.setStartColorVar(cc.color(128,128,128,0));
- this.setEndColor(cc.color(128,128,128,255));
- this.setEndColorVar(cc.color(128,128,128,0));
- // additive
- this.setBlendAdditive(false);
- return true;
- }
- return false;
- }
- });
- /**
- * Create a spiral particle system
- * @deprecated since v3.0 please use new cc.ParticleSpiral() instead.
- * @return {cc.ParticleSpiral}
- *
- * @example
- * var emitter = cc.ParticleSpiral.create();
- */
- cc.ParticleSpiral.create = function () {
- return new cc.ParticleSpiral();
- };
- /**
- * An explosion particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleExplosion();
- */
- cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion# */{
- /**
- * <p>The cc.ParticleExplosion's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleExplosion()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 300);
- },
- /**
- * initialize an explosion particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(0.1);
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(0, 0));
- // Gravity Mode: speed of particles
- this.setSpeed(70);
- this.setSpeedVar(40);
- // Gravity Mode: radial
- this.setRadialAccel(0);
- this.setRadialAccelVar(0);
- // Gravity Mode: tangential
- this.setTangentialAccel(0);
- this.setTangentialAccelVar(0);
- // angle
- this.setAngle(90);
- this.setAngleVar(360);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, winSize.height / 2);
- this.setPosVar(cc.p(0,0));
- // life of particles
- this.setLife(5.0);
- this.setLifeVar(2);
- // size, in pixels
- this.setStartSize(15.0);
- this.setStartSizeVar(10.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per second
- this.setEmissionRate(this.getTotalParticles() / this.getDuration());
- // color of particles
- this.setStartColor(cc.color(179, 26, 51, 255));
- this.setStartColorVar(cc.color(128, 128, 128, 0));
- this.setEndColor(cc.color(128, 128, 128, 0));
- this.setEndColorVar(cc.color(128, 128, 128, 0));
- // additive
- this.setBlendAdditive(false);
- return true;
- }
- return false;
- }
- });
- /**
- * Create an explosion particle system
- * @deprecated since v3.0 please use new cc.ParticleExplosion() instead.
- * @return {cc.ParticleExplosion}
- *
- * @example
- * var emitter = cc.ParticleExplosion.create();
- */
- cc.ParticleExplosion.create = function () {
- return new cc.ParticleExplosion();
- };
- /**
- * A smoke particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleSmoke();
- */
- cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{
- /**
- * <p>The cc.ParticleSmoke's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSmoke()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100);
- },
- /**
- * initialize a smoke particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- // Emitter mode: Gravity Mode
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(0, 0));
- // Gravity Mode: radial acceleration
- this.setRadialAccel(0);
- this.setRadialAccelVar(0);
- // Gravity Mode: speed of particles
- this.setSpeed(25);
- this.setSpeedVar(10);
- // angle
- this.setAngle(90);
- this.setAngleVar(5);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, 0);
- this.setPosVar(cc.p(20, 0));
- // life of particles
- this.setLife(4);
- this.setLifeVar(1);
- // size, in pixels
- this.setStartSize(60.0);
- this.setStartSizeVar(10.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per frame
- this.setEmissionRate(this.getTotalParticles() / this.getLife());
- // color of particles
- this.setStartColor(cc.color(204, 204, 204, 255));
- this.setStartColorVar(cc.color(5, 5, 5, 0));
- this.setEndColor(cc.color(0, 0, 0, 255));
- this.setEndColorVar(cc.color(0, 0, 0, 0));
- // additive
- this.setBlendAdditive(false);
- return true;
- }
- return false;
- }
- });
- /**
- * Create a smoke particle system
- * @deprecated since v3.0 please use new cc.ParticleSmoke() instead.
- * @return {cc.ParticleSmoke}
- *
- * @example
- * var emitter = cc.ParticleFireworks.create();
- */
- cc.ParticleSmoke.create = function () {
- return new cc.ParticleSmoke();
- };
- /**
- * A snow particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleSnow();
- */
- cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{
- /**
- * <p>The cc.ParticleSnow's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSnow()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 250);
- },
- /**
- * initialize a snow particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- // set gravity mode.
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(0, -1));
- // Gravity Mode: speed of particles
- this.setSpeed(5);
- this.setSpeedVar(1);
- // Gravity Mode: radial
- this.setRadialAccel(0);
- this.setRadialAccelVar(1);
- // Gravity mode: tangential
- this.setTangentialAccel(0);
- this.setTangentialAccelVar(1);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, winSize.height + 10);
- this.setPosVar(cc.p(winSize.width / 2, 0));
- // angle
- this.setAngle(-90);
- this.setAngleVar(5);
- // life of particles
- this.setLife(45);
- this.setLifeVar(15);
- // size, in pixels
- this.setStartSize(10.0);
- this.setStartSizeVar(5.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per second
- this.setEmissionRate(10);
- // color of particles
- this.setStartColor(cc.color(255, 255, 255, 255));
- this.setStartColorVar(cc.color(0, 0, 0, 0));
- this.setEndColor(cc.color(255, 255, 255, 0));
- this.setEndColorVar(cc.color(0, 0, 0, 0));
- // additive
- this.setBlendAdditive(false);
- return true;
- }
- return false;
- }
- });
- /**
- * Create a snow particle system
- * @deprecated since v3.0 please use new cc.ParticleSnow() instead.
- * @return {cc.ParticleSnow}
- *
- * @example
- * var emitter = cc.ParticleSnow.create();
- */
- cc.ParticleSnow.create = function () {
- return new cc.ParticleSnow();
- };
- //! @brief A rain particle system
- /**
- * A rain particle system
- * @class
- * @extends cc.ParticleSystem
- *
- * @example
- * var emitter = new cc.ParticleRain();
- */
- cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{
- /**
- * <p>The cc.ParticleRain's constructor. <br/>
- * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleRain()".<br/>
- * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
- */
- ctor:function () {
- cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1000 : 300);
- },
- /**
- * initialize a rain particle system with number Of Particles
- * @param {Number} numberOfParticles
- * @return {Boolean}
- */
- initWithTotalParticles:function (numberOfParticles) {
- if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
- // duration
- this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
- // Gravity Mode: gravity
- this.setGravity(cc.p(10, -10));
- // Gravity Mode: radial
- this.setRadialAccel(0);
- this.setRadialAccelVar(1);
- // Gravity Mode: tangential
- this.setTangentialAccel(0);
- this.setTangentialAccelVar(1);
- // Gravity Mode: speed of particles
- this.setSpeed(130);
- this.setSpeedVar(30);
- // angle
- this.setAngle(-90);
- this.setAngleVar(5);
- // emitter position
- var winSize = cc.director.getWinSize();
- this.setPosition(winSize.width / 2, winSize.height);
- this.setPosVar(cc.p(winSize.width / 2, 0));
- // life of particles
- this.setLife(4.5);
- this.setLifeVar(0);
- // size, in pixels
- this.setStartSize(4.0);
- this.setStartSizeVar(2.0);
- this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
- // emits per second
- this.setEmissionRate(20);
- // color of particles
- this.setStartColor(cc.color(179, 204, 255, 255));
- this.setStartColorVar(cc.color(0, 0, 0, 0));
- this.setEndColor(cc.color(179, 204, 255, 128));
- this.setEndColorVar(cc.color(0, 0, 0, 0));
- // additive
- this.setBlendAdditive(false);
- return true;
- }
- return false;
- }
- });
- /**
- * Create a rain particle system
- * @deprecated since v3.0 please use cc.ParticleRain() instead.
- * @return {cc.ParticleRain}
- *
- * @example
- * var emitter = cc.ParticleRain.create();
- */
- cc.ParticleRain.create = function () {
- return new cc.ParticleRain();
- };
|