新版播放粒子

添加粒子:

void PopStarManager::AddParticlePool()
{
	CCLOG("popstar---AddParticlePool----1");	
	m_ParticleBatchNodeStar =CCParticleBatchNode::create("pop_stars.png");
	m_ParticleBatchNodeStar->retain();

	if(m_dataGameParticle==NULL)
	{
		m_dataGameParticle = CCDictionary::create();
		m_dataGameParticle->retain();
		vector<string> pArray;
		pArray.push_back("pop_star1000.plist");
		pArray.push_back("pop_star1001.plist");
		pArray.push_back("pop_star1002.plist");
		pArray.push_back("pop_star1003.plist");
		pArray.push_back("pop_star1004.plist");
		
		//CCObject* obj=NULL;
		for(int i=0;i<(int)pArray.size();i++)
		{		
			CCParticleSystemQuad* particleSystem = CCParticleSystemQuad::create(pArray[i].c_str());
			m_dataGameParticle->setObject(particleSystem,pArray[i]);
		}
	}
}

播放粒子:

void PopStarManager::ShowParticle( CCPoint _ptOrigin , int _iCate )
{
	CCParticleSystemQuad* particle = (CCParticleSystemQuad*)m_dataGameParticle->objectForKey(CCString::createWithFormat("pop_star%d.plist",_iCate)->getCString());
	if(particle==NULL) return;
	CCParticleSystemQuad* newParticle = CCParticleSystemQuad::create();
	newParticle->setAngle(particle->getAngle());
	newParticle->setAngleVar(particle->getAngleVar());
	newParticle->setBlendFunc(particle->getBlendFunc());//必须放setBlendAdditive上面
	newParticle->setBlendAdditive(particle->isBlendAdditive());
	
	newParticle->setDuration(particle->getDuration());
	newParticle->setTotalParticles(newParticle->getTotalParticles());

	newParticle->setContentSize(particle->getContentSize());
	newParticle->setEndColor(particle->getEndColor());
	newParticle->setEndColorVar(particle->getEndColorVar());
	newParticle->setStartColor(particle->getStartColor());
	newParticle->setStartColorVar(particle->getStartColorVar());
	newParticle->setStartSize(particle->getStartSize());
	newParticle->setStartSizeVar(particle->getStartSizeVar());
	newParticle->setEndSize(particle->getEndSize());
	newParticle->setEndSizeVar(particle->getEndSizeVar());
	newParticle->setPosition(particle->getPosition());
	newParticle->setPosVar(particle->getPosVar());
	newParticle->setStartSpin(particle->getStartSpin());
	newParticle->setStartSpinVar(particle->getStartSpinVar());
	newParticle->setEndSpin(particle->getEndSpin());
	newParticle->setEndSpinVar(particle->getEndSpinVar());

	newParticle->setEmitterMode(particle->getEmitterMode());

	if( newParticle->getEmitterMode() == kCCParticleModeGravity ) 
	{
		// gravity
		newParticle->setGravity(particle->getGravity());

		// speed
		newParticle->setSpeed(particle->getSpeed());
		newParticle->setSpeedVar(particle->getSpeedVar());

		// radial acceleration
		newParticle->setRadialAccel(particle->getRadialAccel());
		newParticle->setRadialAccelVar(particle->getRadialAccelVar());


		// tangential acceleration
		newParticle->setTangentialAccel(particle->getTangentialAccel());
		newParticle->setTangentialAccelVar(particle->getTangentialAccelVar());
		// rotation is dir
		newParticle->setRotationIsDir(particle->getRotationIsDir());
	}

	// or Mode B: radius movement
	else if(  newParticle->getEmitterMode()  == kCCParticleModeRadius) 
	{
		newParticle->setStartRadius(particle->getStartRadius());
		newParticle->setStartRadiusVar(particle->getStartRadiusVar());
		newParticle->setEndRadius(particle->getEndRadius());
		newParticle->setEndRadiusVar(particle->getEndRadiusVar());
		newParticle->setRotatePerSecond(particle->getRotatePerSecond());
		newParticle->setRotatePerSecondVar(particle->getRotatePerSecondVar());
	}
	newParticle->setLife(particle->getLife());
	newParticle->setLifeVar(particle->getLifeVar());
	newParticle->setEmissionRate(particle->getEmissionRate());
	newParticle->setTexture(particle->getTexture());
	newParticle->setAutoRemoveOnFinish(true);

	
	newParticle->setPosition(_ptOrigin);
	m_ParticleBatchNodeStar->addChild(newParticle);
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值