2011-03-19 10:07:16 +08:00
|
|
|
/****************************************************************************
|
2012-09-24 21:22:20 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2011-03-19 10:07:16 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
2011-07-04 19:20:16 +08:00
|
|
|
Copyright (c) 2011 Zynga Inc.
|
2011-03-19 10:07:16 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
#include "CCParticleExamples.h"
|
|
|
|
#include "CCDirector.h"
|
2012-06-19 16:20:46 +08:00
|
|
|
#include "textures/CCTextureCache.h"
|
|
|
|
#include "support/CCPointExtension.h"
|
2012-11-08 12:02:58 +08:00
|
|
|
#include "firePngData.h"
|
|
|
|
#include "platform/CCImage.h"
|
2012-04-18 18:43:45 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
2010-12-28 14:04:28 +08:00
|
|
|
//
|
|
|
|
// ParticleFire
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
static Texture2D* getDefaultTexture()
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = NULL;
|
|
|
|
Image* pImage = NULL;
|
2012-11-08 12:02:58 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
bool bRet = false;
|
|
|
|
const char* key = "__firePngData";
|
2013-06-20 14:13:12 +08:00
|
|
|
pTexture = TextureCache::sharedTextureCache()->textureForKey(key);
|
2012-11-08 12:02:58 +08:00
|
|
|
CC_BREAK_IF(pTexture != NULL);
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
pImage = new Image();
|
2012-12-27 16:07:48 +08:00
|
|
|
CC_BREAK_IF(NULL == pImage);
|
2013-06-20 14:13:12 +08:00
|
|
|
bRet = pImage->initWithImageData((void*)__firePngData, sizeof(__firePngData), Image::kFmtPng);
|
2012-11-08 12:02:58 +08:00
|
|
|
CC_BREAK_IF(!bRet);
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
pTexture = TextureCache::sharedTextureCache()->addUIImage(pImage, key);
|
2012-11-08 12:02:58 +08:00
|
|
|
} while (0);
|
|
|
|
|
2012-12-27 15:42:55 +08:00
|
|
|
CC_SAFE_RELEASE(pImage);
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
return pTexture;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFire* ParticleFire::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFire* pRet = new ParticleFire();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFire* ParticleFire::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFire* pRet = new ParticleFire();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration = kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode
|
2013-06-20 14:13:12 +08:00
|
|
|
this->_emitterMode = kParticleModeGravity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
|
|
|
this->modeA.gravity = ccp(0,0);
|
|
|
|
|
|
|
|
// Gravity Mode: radial acceleration
|
|
|
|
this->modeA.radialAccel = 0;
|
|
|
|
this->modeA.radialAccelVar = 0;
|
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
|
|
|
this->modeA.speed = 60;
|
|
|
|
this->modeA.speedVar = 20;
|
|
|
|
|
|
|
|
// starting angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = 90;
|
|
|
|
_angleVar = 10;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, 60));
|
2013-06-15 14:03:30 +08:00
|
|
|
this->_posVar = ccp(40, 20);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 3;
|
|
|
|
_lifeVar = 0.25f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 54.0f;
|
|
|
|
_startSizeVar = 10.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per frame
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = _totalParticles/_life;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.76f;
|
|
|
|
_startColor.g = 0.25f;
|
|
|
|
_startColor.b = 0.12f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.0f;
|
|
|
|
_startColorVar.g = 0.0f;
|
|
|
|
_startColorVar.b = 0.0f;
|
|
|
|
_startColorVar.a = 0.0f;
|
|
|
|
_endColor.r = 0.0f;
|
|
|
|
_endColor.g = 0.0f;
|
|
|
|
_endColor.b = 0.0f;
|
|
|
|
_endColor.a = 1.0f;
|
|
|
|
_endColorVar.r = 0.0f;
|
|
|
|
_endColorVar.g = 0.0f;
|
|
|
|
_endColorVar.b = 0.0f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// ParticleFireworks
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFireworks* ParticleFireworks::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFireworks* pRet = new ParticleFireworks();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFireworks* ParticleFireworks::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFireworks* pRet = new ParticleFireworks();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration= kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode
|
2013-06-20 14:13:12 +08:00
|
|
|
this->_emitterMode = kParticleModeGravity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
|
|
|
this->modeA.gravity = ccp(0,-90);
|
|
|
|
|
|
|
|
// Gravity Mode: radial
|
|
|
|
this->modeA.radialAccel = 0;
|
|
|
|
this->modeA.radialAccelVar = 0;
|
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
|
|
|
this->modeA.speed = 180;
|
|
|
|
this->modeA.speedVar = 50;
|
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
this->_angle= 90;
|
|
|
|
this->_angleVar = 20;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
this->_life = 3.5f;
|
|
|
|
this->_lifeVar = 1;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per frame
|
2013-06-15 14:03:30 +08:00
|
|
|
this->_emissionRate = _totalParticles/_life;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.5f;
|
|
|
|
_startColor.g = 0.5f;
|
|
|
|
_startColor.b = 0.5f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.5f;
|
|
|
|
_startColorVar.g = 0.5f;
|
|
|
|
_startColorVar.b = 0.5f;
|
|
|
|
_startColorVar.a = 0.1f;
|
|
|
|
_endColor.r = 0.1f;
|
|
|
|
_endColor.g = 0.1f;
|
|
|
|
_endColor.b = 0.1f;
|
|
|
|
_endColor.a = 0.2f;
|
|
|
|
_endColorVar.r = 0.1f;
|
|
|
|
_endColorVar.g = 0.1f;
|
|
|
|
_endColorVar.b = 0.1f;
|
|
|
|
_endColorVar.a = 0.2f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 8.0f;
|
|
|
|
_startSizeVar = 2.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// ParticleSun
|
|
|
|
//
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSun* ParticleSun::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSun* pRet = new ParticleSun();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSun* ParticleSun::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSun* pRet = new ParticleSun();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration = kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode
|
2013-06-20 14:13:12 +08:00
|
|
|
setEmitterMode(kParticleModeGravity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
2013-02-27 16:46:05 +08:00
|
|
|
setGravity(ccp(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity mode: radial acceleration
|
2013-02-27 16:46:05 +08:00
|
|
|
setRadialAccel(0);
|
|
|
|
setRadialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity mode: speed of particles
|
2013-02-27 16:46:05 +08:00
|
|
|
setSpeed(20);
|
|
|
|
setSpeedVar(5);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = 90;
|
|
|
|
_angleVar = 360;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-06-20 14:13:12 +08:00
|
|
|
setPosVar(PointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 1;
|
|
|
|
_lifeVar = 0.5f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 30.0f;
|
|
|
|
_startSizeVar = 10.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per seconds
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = _totalParticles/_life;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.76f;
|
|
|
|
_startColor.g = 0.25f;
|
|
|
|
_startColor.b = 0.12f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.0f;
|
|
|
|
_startColorVar.g = 0.0f;
|
|
|
|
_startColorVar.b = 0.0f;
|
|
|
|
_startColorVar.a = 0.0f;
|
|
|
|
_endColor.r = 0.0f;
|
|
|
|
_endColor.g = 0.0f;
|
|
|
|
_endColor.b = 0.0f;
|
|
|
|
_endColor.a = 1.0f;
|
|
|
|
_endColorVar.r = 0.0f;
|
|
|
|
_endColorVar.g = 0.0f;
|
|
|
|
_endColorVar.b = 0.0f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// ParticleGalaxy
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleGalaxy* ParticleGalaxy::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleGalaxy* pRet = new ParticleGalaxy();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleGalaxy* ParticleGalaxy::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleGalaxy* pRet = new ParticleGalaxy();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration = kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode
|
2013-06-20 14:13:12 +08:00
|
|
|
setEmitterMode(kParticleModeGravity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
2013-02-27 16:46:05 +08:00
|
|
|
setGravity(ccp(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
2013-02-27 16:46:05 +08:00
|
|
|
setSpeed(60);
|
|
|
|
setSpeedVar(10);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: radial
|
2013-02-27 16:46:05 +08:00
|
|
|
setRadialAccel(-80);
|
|
|
|
setRadialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
// Gravity Mode: tangential
|
2013-02-27 16:46:05 +08:00
|
|
|
setTangentialAccel(80);
|
|
|
|
setTangentialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = 90;
|
|
|
|
_angleVar = 360;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-06-20 14:13:12 +08:00
|
|
|
setPosVar(PointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 4;
|
|
|
|
_lifeVar = 1;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 37.0f;
|
|
|
|
_startSizeVar = 10.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per second
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = _totalParticles/_life;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.12f;
|
|
|
|
_startColor.g = 0.25f;
|
|
|
|
_startColor.b = 0.76f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.0f;
|
|
|
|
_startColorVar.g = 0.0f;
|
|
|
|
_startColorVar.b = 0.0f;
|
|
|
|
_startColorVar.a = 0.0f;
|
|
|
|
_endColor.r = 0.0f;
|
|
|
|
_endColor.g = 0.0f;
|
|
|
|
_endColor.b = 0.0f;
|
|
|
|
_endColor.a = 1.0f;
|
|
|
|
_endColorVar.r = 0.0f;
|
|
|
|
_endColorVar.g = 0.0f;
|
|
|
|
_endColorVar.b = 0.0f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// ParticleFlower
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFlower* ParticleFlower::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFlower* pRet = new ParticleFlower();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFlower* ParticleFlower::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleFlower* pRet = new ParticleFlower();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration = kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode
|
2013-06-20 14:13:12 +08:00
|
|
|
setEmitterMode(kParticleModeGravity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
2013-02-27 16:46:05 +08:00
|
|
|
setGravity(ccp(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
2013-02-27 16:46:05 +08:00
|
|
|
setSpeed(80);
|
|
|
|
setSpeedVar(10);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: radial
|
2013-02-27 16:46:05 +08:00
|
|
|
setRadialAccel(-60);
|
|
|
|
setRadialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
// Gravity Mode: tangential
|
2013-02-27 16:46:05 +08:00
|
|
|
setTangentialAccel(15);
|
|
|
|
setTangentialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = 90;
|
|
|
|
_angleVar = 360;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-06-20 14:13:12 +08:00
|
|
|
setPosVar(PointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 4;
|
|
|
|
_lifeVar = 1;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 30.0f;
|
|
|
|
_startSizeVar = 10.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per second
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = _totalParticles/_life;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.50f;
|
|
|
|
_startColor.g = 0.50f;
|
|
|
|
_startColor.b = 0.50f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.5f;
|
|
|
|
_startColorVar.g = 0.5f;
|
|
|
|
_startColorVar.b = 0.5f;
|
|
|
|
_startColorVar.a = 0.5f;
|
|
|
|
_endColor.r = 0.0f;
|
|
|
|
_endColor.g = 0.0f;
|
|
|
|
_endColor.b = 0.0f;
|
|
|
|
_endColor.a = 1.0f;
|
|
|
|
_endColorVar.r = 0.0f;
|
|
|
|
_endColorVar.g = 0.0f;
|
|
|
|
_endColorVar.b = 0.0f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// ParticleMeteor
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleMeteor * ParticleMeteor::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleMeteor *pRet = new ParticleMeteor();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleMeteor* ParticleMeteor::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleMeteor* pRet = new ParticleMeteor();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration = kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode
|
2013-06-20 14:13:12 +08:00
|
|
|
setEmitterMode(kParticleModeGravity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
2013-02-27 16:46:05 +08:00
|
|
|
setGravity(ccp(-200,200));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
2013-02-27 16:46:05 +08:00
|
|
|
setSpeed(15);
|
|
|
|
setSpeedVar(5);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: radial
|
2013-02-27 16:46:05 +08:00
|
|
|
setRadialAccel(0);
|
|
|
|
setRadialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
// Gravity Mode: tangential
|
2013-02-27 16:46:05 +08:00
|
|
|
setTangentialAccel(0);
|
|
|
|
setTangentialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = 90;
|
|
|
|
_angleVar = 360;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-06-20 14:13:12 +08:00
|
|
|
setPosVar(PointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 2;
|
|
|
|
_lifeVar = 1;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 60.0f;
|
|
|
|
_startSizeVar = 10.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per second
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = _totalParticles/_life;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.2f;
|
|
|
|
_startColor.g = 0.4f;
|
|
|
|
_startColor.b = 0.7f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.0f;
|
|
|
|
_startColorVar.g = 0.0f;
|
|
|
|
_startColorVar.b = 0.2f;
|
|
|
|
_startColorVar.a = 0.1f;
|
|
|
|
_endColor.r = 0.0f;
|
|
|
|
_endColor.g = 0.0f;
|
|
|
|
_endColor.b = 0.0f;
|
|
|
|
_endColor.a = 1.0f;
|
|
|
|
_endColorVar.r = 0.0f;
|
|
|
|
_endColorVar.g = 0.0f;
|
|
|
|
_endColorVar.b = 0.0f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// ParticleSpiral
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSpiral* ParticleSpiral::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSpiral* pRet = new ParticleSpiral();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSpiral* ParticleSpiral::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSpiral* pRet = new ParticleSpiral();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration = kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode
|
2013-06-20 14:13:12 +08:00
|
|
|
setEmitterMode(kParticleModeGravity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
2013-02-27 16:46:05 +08:00
|
|
|
setGravity(ccp(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
2013-02-27 16:46:05 +08:00
|
|
|
setSpeed(150);
|
|
|
|
setSpeedVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: radial
|
2013-02-27 16:46:05 +08:00
|
|
|
setRadialAccel(-380);
|
|
|
|
setRadialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
// Gravity Mode: tangential
|
2013-02-27 16:46:05 +08:00
|
|
|
setTangentialAccel(45);
|
|
|
|
setTangentialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = 90;
|
|
|
|
_angleVar = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-06-20 14:13:12 +08:00
|
|
|
setPosVar(PointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 12;
|
|
|
|
_lifeVar = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 20.0f;
|
|
|
|
_startSizeVar = 0.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per second
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = _totalParticles/_life;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.5f;
|
|
|
|
_startColor.g = 0.5f;
|
|
|
|
_startColor.b = 0.5f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.5f;
|
|
|
|
_startColorVar.g = 0.5f;
|
|
|
|
_startColorVar.b = 0.5f;
|
|
|
|
_startColorVar.a = 0.0f;
|
|
|
|
_endColor.r = 0.5f;
|
|
|
|
_endColor.g = 0.5f;
|
|
|
|
_endColor.b = 0.5f;
|
|
|
|
_endColor.a = 1.0f;
|
|
|
|
_endColorVar.r = 0.5f;
|
|
|
|
_endColorVar.g = 0.5f;
|
|
|
|
_endColorVar.b = 0.5f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// ParticleExplosion
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleExplosion* ParticleExplosion::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleExplosion* pRet = new ParticleExplosion();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleExplosion* ParticleExplosion::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleExplosion* pRet = new ParticleExplosion();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-15 14:03:30 +08:00
|
|
|
_duration = 0.1f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
setEmitterMode(kParticleModeGravity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
2013-02-27 16:46:05 +08:00
|
|
|
setGravity(ccp(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
2013-02-27 16:46:05 +08:00
|
|
|
setSpeed(70);
|
|
|
|
setSpeedVar(40);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: radial
|
2013-02-27 16:46:05 +08:00
|
|
|
setRadialAccel(0);
|
|
|
|
setRadialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
// Gravity Mode: tangential
|
2013-02-27 16:46:05 +08:00
|
|
|
setTangentialAccel(0);
|
|
|
|
setTangentialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = 90;
|
|
|
|
_angleVar = 360;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-06-20 14:13:12 +08:00
|
|
|
setPosVar(PointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 5.0f;
|
|
|
|
_lifeVar = 2;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 15.0f;
|
|
|
|
_startSizeVar = 10.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per second
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = _totalParticles/_duration;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.7f;
|
|
|
|
_startColor.g = 0.1f;
|
|
|
|
_startColor.b = 0.2f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.5f;
|
|
|
|
_startColorVar.g = 0.5f;
|
|
|
|
_startColorVar.b = 0.5f;
|
|
|
|
_startColorVar.a = 0.0f;
|
|
|
|
_endColor.r = 0.5f;
|
|
|
|
_endColor.g = 0.5f;
|
|
|
|
_endColor.b = 0.5f;
|
|
|
|
_endColor.a = 0.0f;
|
|
|
|
_endColorVar.r = 0.5f;
|
|
|
|
_endColorVar.g = 0.5f;
|
|
|
|
_endColorVar.b = 0.5f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// ParticleSmoke
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSmoke* ParticleSmoke::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSmoke* pRet = new ParticleSmoke();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSmoke* ParticleSmoke::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSmoke* pRet = new ParticleSmoke();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration = kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Emitter mode: Gravity Mode
|
2013-06-20 14:13:12 +08:00
|
|
|
setEmitterMode(kParticleModeGravity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
2013-02-27 16:46:05 +08:00
|
|
|
setGravity(ccp(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: radial acceleration
|
2013-02-27 16:46:05 +08:00
|
|
|
setRadialAccel(0);
|
|
|
|
setRadialAccelVar(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
2013-02-27 16:46:05 +08:00
|
|
|
setSpeed(25);
|
|
|
|
setSpeedVar(10);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = 90;
|
|
|
|
_angleVar = 5;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, 0));
|
2013-02-27 16:46:05 +08:00
|
|
|
setPosVar(ccp(20, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 4;
|
|
|
|
_lifeVar = 1;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 60.0f;
|
|
|
|
_startSizeVar = 10.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per frame
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = _totalParticles/_life;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.8f;
|
|
|
|
_startColor.g = 0.8f;
|
|
|
|
_startColor.b = 0.8f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.02f;
|
|
|
|
_startColorVar.g = 0.02f;
|
|
|
|
_startColorVar.b = 0.02f;
|
|
|
|
_startColorVar.a = 0.0f;
|
|
|
|
_endColor.r = 0.0f;
|
|
|
|
_endColor.g = 0.0f;
|
|
|
|
_endColor.b = 0.0f;
|
|
|
|
_endColor.a = 1.0f;
|
|
|
|
_endColorVar.r = 0.0f;
|
|
|
|
_endColorVar.g = 0.0f;
|
|
|
|
_endColorVar.b = 0.0f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2010-12-28 14:04:28 +08:00
|
|
|
//
|
2013-06-20 14:13:12 +08:00
|
|
|
// ParticleSnow
|
2010-12-28 14:04:28 +08:00
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSnow* ParticleSnow::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSnow* pRet = new ParticleSnow();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSnow* ParticleSnow::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleSnow* pRet = new ParticleSnow();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration = kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// set gravity mode.
|
2013-06-20 14:13:12 +08:00
|
|
|
setEmitterMode(kParticleModeGravity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
2013-02-27 16:46:05 +08:00
|
|
|
setGravity(ccp(0,-1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
2013-02-27 16:46:05 +08:00
|
|
|
setSpeed(5);
|
|
|
|
setSpeedVar(1);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: radial
|
2013-02-27 16:46:05 +08:00
|
|
|
setRadialAccel(0);
|
|
|
|
setRadialAccelVar(1);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
// Gravity mode: tangential
|
2013-02-27 16:46:05 +08:00
|
|
|
setTangentialAccel(0);
|
|
|
|
setTangentialAccelVar(1);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height + 10));
|
2013-02-27 16:46:05 +08:00
|
|
|
setPosVar(ccp(winSize.width/2, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = -90;
|
|
|
|
_angleVar = 5;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 45;
|
|
|
|
_lifeVar = 15;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 10.0f;
|
|
|
|
_startSizeVar = 5.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per second
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = 10;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 1.0f;
|
|
|
|
_startColor.g = 1.0f;
|
|
|
|
_startColor.b = 1.0f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.0f;
|
|
|
|
_startColorVar.g = 0.0f;
|
|
|
|
_startColorVar.b = 0.0f;
|
|
|
|
_startColorVar.a = 0.0f;
|
|
|
|
_endColor.r = 1.0f;
|
|
|
|
_endColor.g = 1.0f;
|
|
|
|
_endColor.b = 1.0f;
|
|
|
|
_endColor.a = 0.0f;
|
|
|
|
_endColorVar.r = 0.0f;
|
|
|
|
_endColorVar.g = 0.0f;
|
|
|
|
_endColorVar.b = 0.0f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
|
|
|
//
|
2013-06-20 14:13:12 +08:00
|
|
|
// ParticleRain
|
2010-12-28 14:04:28 +08:00
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleRain* ParticleRain::create()
|
2012-11-01 22:17:12 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleRain* pRet = new ParticleRain();
|
2012-11-01 22:17:12 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleRain* ParticleRain::createWithTotalParticles(unsigned int numberOfParticles)
|
2012-11-08 12:02:58 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
ParticleRain* pRet = new ParticleRain();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
2013-06-20 14:13:12 +08:00
|
|
|
_duration = kParticleDurationInfinity;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
setEmitterMode(kParticleModeGravity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: gravity
|
2013-02-27 16:46:05 +08:00
|
|
|
setGravity(ccp(10,-10));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: radial
|
2013-02-27 16:46:05 +08:00
|
|
|
setRadialAccel(0);
|
|
|
|
setRadialAccelVar(1);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
// Gravity Mode: tangential
|
2013-02-27 16:46:05 +08:00
|
|
|
setTangentialAccel(0);
|
|
|
|
setTangentialAccelVar(1);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Gravity Mode: speed of particles
|
2013-02-27 16:46:05 +08:00
|
|
|
setSpeed(130);
|
|
|
|
setSpeedVar(30);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// angle
|
2013-06-15 14:03:30 +08:00
|
|
|
_angle = -90;
|
|
|
|
_angleVar = 5;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
// emitter position
|
2013-06-20 14:13:12 +08:00
|
|
|
Size winSize = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height));
|
2013-02-27 16:46:05 +08:00
|
|
|
setPosVar(ccp(winSize.width/2, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_life = 4.5f;
|
|
|
|
_lifeVar = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// size, in pixels
|
2013-06-15 14:03:30 +08:00
|
|
|
_startSize = 4.0f;
|
|
|
|
_startSizeVar = 2.0f;
|
2013-06-20 14:13:12 +08:00
|
|
|
_endSize = kParticleStartSizeEqualToEndSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// emits per second
|
2013-06-15 14:03:30 +08:00
|
|
|
_emissionRate = 20;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// color of particles
|
2013-06-15 14:03:30 +08:00
|
|
|
_startColor.r = 0.7f;
|
|
|
|
_startColor.g = 0.8f;
|
|
|
|
_startColor.b = 1.0f;
|
|
|
|
_startColor.a = 1.0f;
|
|
|
|
_startColorVar.r = 0.0f;
|
|
|
|
_startColorVar.g = 0.0f;
|
|
|
|
_startColorVar.b = 0.0f;
|
|
|
|
_startColorVar.a = 0.0f;
|
|
|
|
_endColor.r = 0.7f;
|
|
|
|
_endColor.g = 0.8f;
|
|
|
|
_endColor.b = 1.0f;
|
|
|
|
_endColor.a = 0.5f;
|
|
|
|
_endColorVar.r = 0.0f;
|
|
|
|
_endColorVar.g = 0.0f;
|
|
|
|
_endColorVar.b = 0.0f;
|
|
|
|
_endColorVar.a = 0.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* pTexture = getDefaultTexture();
|
2012-11-08 12:02:58 +08:00
|
|
|
if (pTexture != NULL)
|
|
|
|
{
|
|
|
|
setTexture(pTexture);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// additive
|
2012-06-15 15:10:40 +08:00
|
|
|
this->setBlendAdditive(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-28 14:04:28 +08:00
|
|
|
}
|
2011-03-19 10:07:16 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|