创建此粒子关键在于先创建 ParallaxNode, 再根据需要添加对应元素。
当然,还有根据在上层鼠标位置坐标,在下层相对位置创建粒子位置方法。 用到时再参考示例代码吧。
void ParallaxParticle::onEnter()
{
ParticleDemo::onEnter();
m_background->getParent()->removeChild(m_background, true);
m_background = NULL;
CCParallaxNode* p = CCParallaxNode::create();
addChild(p, 5);
CCSprite *p1 = CCSprite::create(s_back3);
CCSprite *p2 = CCSprite::create(s_back3);
p->addChild( p1, 1, ccp(0.5f,1), ccp(0,250) );
p->addChild(p2, 2, ccp(1.5f,1), ccp(0,50) );
m_emitter = CCParticleFlower::create();
m_emitter->retain();
m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) );
p1->addChild(m_emitter, 10);
m_emitter->setPosition( ccp(250,200) );
CCParticleSun* par = CCParticleSun::create();
p2->addChild(par, 10);
par->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) );
CCActionInterval* move = CCMoveBy::create(4, ccp(300,0));
CCActionInterval* move_back = move->reverse();
CCSequence* seq = CCSequence::create( move, move_back, NULL);
p->runAction(CCRepeatForever::create(seq));
}