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
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
static CCTexture2D* getDefaultTexture()
|
|
|
|
{
|
|
|
|
CCTexture2D* pTexture = NULL;
|
2012-12-27 15:42:55 +08:00
|
|
|
CCImage* pImage = NULL;
|
2012-11-08 12:02:58 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
bool bRet = false;
|
|
|
|
const char* key = "__firePngData";
|
|
|
|
pTexture = CCTextureCache::sharedTextureCache()->textureForKey(key);
|
|
|
|
CC_BREAK_IF(pTexture != NULL);
|
|
|
|
|
2012-12-27 15:42:55 +08:00
|
|
|
pImage = new CCImage();
|
2012-12-27 16:07:48 +08:00
|
|
|
CC_BREAK_IF(NULL == pImage);
|
2012-12-27 15:42:55 +08:00
|
|
|
bRet = pImage->initWithImageData((void*)__firePngData, sizeof(__firePngData), CCImage::kFmtPng);
|
2012-11-08 12:02:58 +08:00
|
|
|
CC_BREAK_IF(!bRet);
|
|
|
|
|
2012-12-27 15:42:55 +08:00
|
|
|
pTexture = CCTextureCache::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;
|
|
|
|
}
|
|
|
|
|
2012-11-01 22:17:12 +08:00
|
|
|
CCParticleFire* CCParticleFire::create()
|
|
|
|
{
|
|
|
|
CCParticleFire* pRet = new CCParticleFire();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleFire* CCParticleFire::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleFire* pRet = new CCParticleFire();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration = kCCParticleDurationInfinity;
|
|
|
|
|
|
|
|
// Gravity Mode
|
|
|
|
this->m_nEmitterMode = kCCParticleModeGravity;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
m_fAngle = 90;
|
|
|
|
m_fAngleVar = 10;
|
|
|
|
|
|
|
|
// emitter position
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
this->setPosition(ccp(winSize.width/2, 60));
|
|
|
|
this->m_tPosVar = ccp(40, 20);
|
|
|
|
|
|
|
|
// life of particles
|
|
|
|
m_fLife = 3;
|
|
|
|
m_fLifeVar = 0.25f;
|
|
|
|
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 54.0f;
|
|
|
|
m_fStartSizeVar = 10.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per frame
|
|
|
|
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.76f;
|
|
|
|
m_tStartColor.g = 0.25f;
|
|
|
|
m_tStartColor.b = 0.12f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.0f;
|
|
|
|
m_tStartColorVar.g = 0.0f;
|
|
|
|
m_tStartColorVar.b = 0.0f;
|
|
|
|
m_tStartColorVar.a = 0.0f;
|
|
|
|
m_tEndColor.r = 0.0f;
|
|
|
|
m_tEndColor.g = 0.0f;
|
|
|
|
m_tEndColor.b = 0.0f;
|
|
|
|
m_tEndColor.a = 1.0f;
|
|
|
|
m_tEndColorVar.r = 0.0f;
|
|
|
|
m_tEndColorVar.g = 0.0f;
|
|
|
|
m_tEndColorVar.b = 0.0f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
|
|
|
|
CCParticleFireworks* CCParticleFireworks::create()
|
|
|
|
{
|
|
|
|
CCParticleFireworks* pRet = new CCParticleFireworks();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleFireworks* CCParticleFireworks::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleFireworks* pRet = new CCParticleFireworks();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration= kCCParticleDurationInfinity;
|
|
|
|
|
|
|
|
// Gravity Mode
|
|
|
|
this->m_nEmitterMode = kCCParticleModeGravity;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
|
|
|
|
|
|
|
// angle
|
|
|
|
this->m_fAngle= 90;
|
|
|
|
this->m_fAngleVar = 20;
|
|
|
|
|
|
|
|
// life of particles
|
|
|
|
this->m_fLife = 3.5f;
|
|
|
|
this->m_fLifeVar = 1;
|
|
|
|
|
|
|
|
// emits per frame
|
|
|
|
this->m_fEmissionRate = m_uTotalParticles/m_fLife;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.5f;
|
|
|
|
m_tStartColor.g = 0.5f;
|
|
|
|
m_tStartColor.b = 0.5f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.5f;
|
|
|
|
m_tStartColorVar.g = 0.5f;
|
|
|
|
m_tStartColorVar.b = 0.5f;
|
|
|
|
m_tStartColorVar.a = 0.1f;
|
|
|
|
m_tEndColor.r = 0.1f;
|
|
|
|
m_tEndColor.g = 0.1f;
|
|
|
|
m_tEndColor.b = 0.1f;
|
|
|
|
m_tEndColor.a = 0.2f;
|
|
|
|
m_tEndColorVar.r = 0.1f;
|
|
|
|
m_tEndColorVar.g = 0.1f;
|
|
|
|
m_tEndColorVar.b = 0.1f;
|
|
|
|
m_tEndColorVar.a = 0.2f;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 8.0f;
|
|
|
|
m_fStartSizeVar = 2.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
CCParticleSun* CCParticleSun::create()
|
|
|
|
{
|
|
|
|
CCParticleSun* pRet = new CCParticleSun();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleSun* CCParticleSun::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleSun* pRet = new CCParticleSun();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::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
|
|
|
|
m_fDuration = kCCParticleDurationInfinity;
|
|
|
|
|
|
|
|
// Gravity Mode
|
2013-02-27 16:46:05 +08:00
|
|
|
setEmitterMode(kCCParticleModeGravity);
|
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
|
|
|
|
m_fAngle = 90;
|
|
|
|
m_fAngleVar = 360;
|
|
|
|
|
|
|
|
// emitter position
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-02-27 16:46:05 +08:00
|
|
|
setPosVar(CCPointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
|
|
|
m_fLife = 1;
|
|
|
|
m_fLifeVar = 0.5f;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 30.0f;
|
|
|
|
m_fStartSizeVar = 10.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per seconds
|
|
|
|
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.76f;
|
|
|
|
m_tStartColor.g = 0.25f;
|
|
|
|
m_tStartColor.b = 0.12f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.0f;
|
|
|
|
m_tStartColorVar.g = 0.0f;
|
|
|
|
m_tStartColorVar.b = 0.0f;
|
|
|
|
m_tStartColorVar.a = 0.0f;
|
|
|
|
m_tEndColor.r = 0.0f;
|
|
|
|
m_tEndColor.g = 0.0f;
|
|
|
|
m_tEndColor.b = 0.0f;
|
|
|
|
m_tEndColor.a = 1.0f;
|
|
|
|
m_tEndColorVar.r = 0.0f;
|
|
|
|
m_tEndColorVar.g = 0.0f;
|
|
|
|
m_tEndColorVar.b = 0.0f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
|
|
|
|
CCParticleGalaxy* CCParticleGalaxy::create()
|
|
|
|
{
|
|
|
|
CCParticleGalaxy* pRet = new CCParticleGalaxy();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleGalaxy* CCParticleGalaxy::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleGalaxy* pRet = new CCParticleGalaxy();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration = kCCParticleDurationInfinity;
|
|
|
|
|
|
|
|
// Gravity Mode
|
2013-02-27 16:46:05 +08:00
|
|
|
setEmitterMode(kCCParticleModeGravity);
|
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
|
|
|
|
m_fAngle = 90;
|
|
|
|
m_fAngleVar = 360;
|
|
|
|
|
|
|
|
// emitter position
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-02-27 16:46:05 +08:00
|
|
|
setPosVar(CCPointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
|
|
|
m_fLife = 4;
|
|
|
|
m_fLifeVar = 1;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 37.0f;
|
|
|
|
m_fStartSizeVar = 10.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per second
|
|
|
|
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.12f;
|
|
|
|
m_tStartColor.g = 0.25f;
|
|
|
|
m_tStartColor.b = 0.76f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.0f;
|
|
|
|
m_tStartColorVar.g = 0.0f;
|
|
|
|
m_tStartColorVar.b = 0.0f;
|
|
|
|
m_tStartColorVar.a = 0.0f;
|
|
|
|
m_tEndColor.r = 0.0f;
|
|
|
|
m_tEndColor.g = 0.0f;
|
|
|
|
m_tEndColor.b = 0.0f;
|
|
|
|
m_tEndColor.a = 1.0f;
|
|
|
|
m_tEndColorVar.r = 0.0f;
|
|
|
|
m_tEndColorVar.g = 0.0f;
|
|
|
|
m_tEndColorVar.b = 0.0f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
|
|
|
|
CCParticleFlower* CCParticleFlower::create()
|
|
|
|
{
|
|
|
|
CCParticleFlower* pRet = new CCParticleFlower();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleFlower* CCParticleFlower::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleFlower* pRet = new CCParticleFlower();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration = kCCParticleDurationInfinity;
|
|
|
|
|
|
|
|
// Gravity Mode
|
2013-02-27 16:46:05 +08:00
|
|
|
setEmitterMode(kCCParticleModeGravity);
|
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
|
|
|
|
m_fAngle = 90;
|
|
|
|
m_fAngleVar = 360;
|
|
|
|
|
|
|
|
// emitter position
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-02-27 16:46:05 +08:00
|
|
|
setPosVar(CCPointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
|
|
|
m_fLife = 4;
|
|
|
|
m_fLifeVar = 1;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 30.0f;
|
|
|
|
m_fStartSizeVar = 10.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per second
|
|
|
|
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.50f;
|
|
|
|
m_tStartColor.g = 0.50f;
|
|
|
|
m_tStartColor.b = 0.50f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.5f;
|
|
|
|
m_tStartColorVar.g = 0.5f;
|
|
|
|
m_tStartColorVar.b = 0.5f;
|
|
|
|
m_tStartColorVar.a = 0.5f;
|
|
|
|
m_tEndColor.r = 0.0f;
|
|
|
|
m_tEndColor.g = 0.0f;
|
|
|
|
m_tEndColor.b = 0.0f;
|
|
|
|
m_tEndColor.a = 1.0f;
|
|
|
|
m_tEndColorVar.r = 0.0f;
|
|
|
|
m_tEndColorVar.g = 0.0f;
|
|
|
|
m_tEndColorVar.b = 0.0f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
|
|
|
|
CCParticleMeteor * CCParticleMeteor::create()
|
|
|
|
{
|
|
|
|
CCParticleMeteor *pRet = new CCParticleMeteor();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleMeteor* CCParticleMeteor::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleMeteor* pRet = new CCParticleMeteor();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration = kCCParticleDurationInfinity;
|
|
|
|
|
|
|
|
// Gravity Mode
|
2013-02-27 16:46:05 +08:00
|
|
|
setEmitterMode(kCCParticleModeGravity);
|
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
|
|
|
|
m_fAngle = 90;
|
|
|
|
m_fAngleVar = 360;
|
|
|
|
|
|
|
|
// emitter position
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-02-27 16:46:05 +08:00
|
|
|
setPosVar(CCPointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
|
|
|
m_fLife = 2;
|
|
|
|
m_fLifeVar = 1;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 60.0f;
|
|
|
|
m_fStartSizeVar = 10.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per second
|
|
|
|
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.2f;
|
|
|
|
m_tStartColor.g = 0.4f;
|
|
|
|
m_tStartColor.b = 0.7f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.0f;
|
|
|
|
m_tStartColorVar.g = 0.0f;
|
|
|
|
m_tStartColorVar.b = 0.2f;
|
|
|
|
m_tStartColorVar.a = 0.1f;
|
|
|
|
m_tEndColor.r = 0.0f;
|
|
|
|
m_tEndColor.g = 0.0f;
|
|
|
|
m_tEndColor.b = 0.0f;
|
|
|
|
m_tEndColor.a = 1.0f;
|
|
|
|
m_tEndColorVar.r = 0.0f;
|
|
|
|
m_tEndColorVar.g = 0.0f;
|
|
|
|
m_tEndColorVar.b = 0.0f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
|
|
|
|
CCParticleSpiral* CCParticleSpiral::create()
|
|
|
|
{
|
|
|
|
CCParticleSpiral* pRet = new CCParticleSpiral();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleSpiral* CCParticleSpiral::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleSpiral* pRet = new CCParticleSpiral();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration = kCCParticleDurationInfinity;
|
|
|
|
|
|
|
|
// Gravity Mode
|
2013-02-27 16:46:05 +08:00
|
|
|
setEmitterMode(kCCParticleModeGravity);
|
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
|
|
|
|
m_fAngle = 90;
|
|
|
|
m_fAngleVar = 0;
|
|
|
|
|
|
|
|
// emitter position
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-02-27 16:46:05 +08:00
|
|
|
setPosVar(CCPointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
|
|
|
m_fLife = 12;
|
|
|
|
m_fLifeVar = 0;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 20.0f;
|
|
|
|
m_fStartSizeVar = 0.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per second
|
|
|
|
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.5f;
|
|
|
|
m_tStartColor.g = 0.5f;
|
|
|
|
m_tStartColor.b = 0.5f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.5f;
|
|
|
|
m_tStartColorVar.g = 0.5f;
|
|
|
|
m_tStartColorVar.b = 0.5f;
|
|
|
|
m_tStartColorVar.a = 0.0f;
|
|
|
|
m_tEndColor.r = 0.5f;
|
|
|
|
m_tEndColor.g = 0.5f;
|
|
|
|
m_tEndColor.b = 0.5f;
|
|
|
|
m_tEndColor.a = 1.0f;
|
|
|
|
m_tEndColorVar.r = 0.5f;
|
|
|
|
m_tEndColorVar.g = 0.5f;
|
|
|
|
m_tEndColorVar.b = 0.5f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
|
|
|
|
CCParticleExplosion* CCParticleExplosion::create()
|
|
|
|
{
|
|
|
|
CCParticleExplosion* pRet = new CCParticleExplosion();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleExplosion* CCParticleExplosion::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleExplosion* pRet = new CCParticleExplosion();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration = 0.1f;
|
|
|
|
|
2013-02-27 16:46:05 +08:00
|
|
|
setEmitterMode(kCCParticleModeGravity);
|
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
|
|
|
|
m_fAngle = 90;
|
|
|
|
m_fAngleVar = 360;
|
|
|
|
|
|
|
|
// emitter position
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
this->setPosition(ccp(winSize.width/2, winSize.height/2));
|
2013-02-27 16:46:05 +08:00
|
|
|
setPosVar(CCPointZero);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// life of particles
|
|
|
|
m_fLife = 5.0f;
|
|
|
|
m_fLifeVar = 2;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 15.0f;
|
|
|
|
m_fStartSizeVar = 10.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per second
|
|
|
|
m_fEmissionRate = m_uTotalParticles/m_fDuration;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.7f;
|
|
|
|
m_tStartColor.g = 0.1f;
|
|
|
|
m_tStartColor.b = 0.2f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.5f;
|
|
|
|
m_tStartColorVar.g = 0.5f;
|
|
|
|
m_tStartColorVar.b = 0.5f;
|
|
|
|
m_tStartColorVar.a = 0.0f;
|
|
|
|
m_tEndColor.r = 0.5f;
|
|
|
|
m_tEndColor.g = 0.5f;
|
|
|
|
m_tEndColor.b = 0.5f;
|
|
|
|
m_tEndColor.a = 0.0f;
|
|
|
|
m_tEndColorVar.r = 0.5f;
|
|
|
|
m_tEndColorVar.g = 0.5f;
|
|
|
|
m_tEndColorVar.b = 0.5f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
|
|
|
|
CCParticleSmoke* CCParticleSmoke::create()
|
|
|
|
{
|
|
|
|
CCParticleSmoke* pRet = new CCParticleSmoke();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleSmoke* CCParticleSmoke::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleSmoke* pRet = new CCParticleSmoke();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration = kCCParticleDurationInfinity;
|
|
|
|
|
|
|
|
// Emitter mode: Gravity Mode
|
2013-02-27 16:46:05 +08:00
|
|
|
setEmitterMode(kCCParticleModeGravity);
|
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
|
|
|
|
m_fAngle = 90;
|
|
|
|
m_fAngleVar = 5;
|
|
|
|
|
|
|
|
// emitter position
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
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
|
|
|
|
m_fLife = 4;
|
|
|
|
m_fLifeVar = 1;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 60.0f;
|
|
|
|
m_fStartSizeVar = 10.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per frame
|
|
|
|
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.8f;
|
|
|
|
m_tStartColor.g = 0.8f;
|
|
|
|
m_tStartColor.b = 0.8f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.02f;
|
|
|
|
m_tStartColorVar.g = 0.02f;
|
|
|
|
m_tStartColorVar.b = 0.02f;
|
|
|
|
m_tStartColorVar.a = 0.0f;
|
|
|
|
m_tEndColor.r = 0.0f;
|
|
|
|
m_tEndColor.g = 0.0f;
|
|
|
|
m_tEndColor.b = 0.0f;
|
|
|
|
m_tEndColor.a = 1.0f;
|
|
|
|
m_tEndColorVar.r = 0.0f;
|
|
|
|
m_tEndColorVar.g = 0.0f;
|
|
|
|
m_tEndColorVar.b = 0.0f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
//
|
|
|
|
// CCParticleSnow
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
|
|
|
CCParticleSnow* CCParticleSnow::create()
|
|
|
|
{
|
|
|
|
CCParticleSnow* pRet = new CCParticleSnow();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleSnow* CCParticleSnow::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleSnow* pRet = new CCParticleSnow();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration = kCCParticleDurationInfinity;
|
|
|
|
|
|
|
|
// set gravity mode.
|
2013-02-27 16:46:05 +08:00
|
|
|
setEmitterMode(kCCParticleModeGravity);
|
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
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
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
|
|
|
|
m_fAngle = -90;
|
|
|
|
m_fAngleVar = 5;
|
|
|
|
|
|
|
|
// life of particles
|
|
|
|
m_fLife = 45;
|
|
|
|
m_fLifeVar = 15;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 10.0f;
|
|
|
|
m_fStartSizeVar = 5.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per second
|
|
|
|
m_fEmissionRate = 10;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 1.0f;
|
|
|
|
m_tStartColor.g = 1.0f;
|
|
|
|
m_tStartColor.b = 1.0f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.0f;
|
|
|
|
m_tStartColorVar.g = 0.0f;
|
|
|
|
m_tStartColorVar.b = 0.0f;
|
|
|
|
m_tStartColorVar.a = 0.0f;
|
|
|
|
m_tEndColor.r = 1.0f;
|
|
|
|
m_tEndColor.g = 1.0f;
|
|
|
|
m_tEndColor.b = 1.0f;
|
|
|
|
m_tEndColor.a = 0.0f;
|
|
|
|
m_tEndColorVar.r = 0.0f;
|
|
|
|
m_tEndColorVar.g = 0.0f;
|
|
|
|
m_tEndColorVar.b = 0.0f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|
|
|
}
|
|
|
|
//
|
|
|
|
// CCParticleRain
|
|
|
|
//
|
2012-11-01 22:17:12 +08:00
|
|
|
|
|
|
|
CCParticleRain* CCParticleRain::create()
|
|
|
|
{
|
|
|
|
CCParticleRain* pRet = new CCParticleRain();
|
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCParticleRain* CCParticleRain::createWithTotalParticles(unsigned int numberOfParticles)
|
|
|
|
{
|
|
|
|
CCParticleRain* pRet = new CCParticleRain();
|
|
|
|
if (pRet && pRet->initWithTotalParticles(numberOfParticles))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-07-04 19:20:16 +08:00
|
|
|
bool CCParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
|
2010-12-28 14:04:28 +08:00
|
|
|
{
|
2012-04-25 16:18:04 +08:00
|
|
|
if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// duration
|
|
|
|
m_fDuration = kCCParticleDurationInfinity;
|
|
|
|
|
2013-02-27 16:46:05 +08:00
|
|
|
setEmitterMode(kCCParticleModeGravity);
|
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
|
|
|
|
m_fAngle = -90;
|
|
|
|
m_fAngleVar = 5;
|
|
|
|
|
|
|
|
|
|
|
|
// emitter position
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
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
|
|
|
|
m_fLife = 4.5f;
|
|
|
|
m_fLifeVar = 0;
|
|
|
|
|
|
|
|
// size, in pixels
|
|
|
|
m_fStartSize = 4.0f;
|
|
|
|
m_fStartSizeVar = 2.0f;
|
|
|
|
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
|
|
|
|
|
|
|
// emits per second
|
|
|
|
m_fEmissionRate = 20;
|
|
|
|
|
|
|
|
// color of particles
|
|
|
|
m_tStartColor.r = 0.7f;
|
|
|
|
m_tStartColor.g = 0.8f;
|
|
|
|
m_tStartColor.b = 1.0f;
|
|
|
|
m_tStartColor.a = 1.0f;
|
|
|
|
m_tStartColorVar.r = 0.0f;
|
|
|
|
m_tStartColorVar.g = 0.0f;
|
|
|
|
m_tStartColorVar.b = 0.0f;
|
|
|
|
m_tStartColorVar.a = 0.0f;
|
|
|
|
m_tEndColor.r = 0.7f;
|
|
|
|
m_tEndColor.g = 0.8f;
|
|
|
|
m_tEndColor.b = 1.0f;
|
|
|
|
m_tEndColor.a = 0.5f;
|
|
|
|
m_tEndColorVar.r = 0.0f;
|
|
|
|
m_tEndColorVar.g = 0.0f;
|
|
|
|
m_tEndColorVar.b = 0.0f;
|
|
|
|
m_tEndColorVar.a = 0.0f;
|
|
|
|
|
2012-11-08 12:02:58 +08:00
|
|
|
CCTexture2D* pTexture = getDefaultTexture();
|
|
|
|
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
|