void showStarParticleEffect(int color,Point position,Node* node){ CCLOG("Particle Particle Particle"); ParticleExplosion* effect = ParticleExplosion::create(); effect->setTexture(Director::getInstance()->getTextureCache()->addImage("star.png")); effect->setTotalParticles(300); effect->setStartColor(getColor4F(color)); effect->setStartColorVar(Color4F(0,0,0,1)); effect->setEndColor(getColor4F(color)); effect->setEndColorVar(Color4F(0,0,0,1)); effect->setStartSize(25.0f); // 初始化粒子元素的尺寸 effect->setGravity(Point(0,-400)); effect->setDuration(0.2f); effect->setLife(2.0f); effect->setSpeed(300.0f); effect->setSpeedVar(10); effect->setPosition(position); node->addChild(effect); }
void CC3UniformlyEvolvingPointParticle::updateBeforeTransform( CC3NodeUpdatingVisitor* visitor ) { super::updateBeforeTransform( visitor ); if( !isAlive() ) return; GLfloat dt = visitor->getDeltaTime(); if ( hasSize() ) setSize( getSize() + (m_sizeVelocity * dt) ); if ( hasColor() ) { // We have to do the math on each component instead of using the color math functions // because the functions clamp prematurely, and we need negative values for the velocity. ccColor4F currColor = getColor4F(); setColor4F( ccc4f(CLAMP(currColor.r + (m_colorVelocity.r * dt), 0.0f, 1.0f), CLAMP(currColor.g + (m_colorVelocity.g * dt), 0.0f, 1.0f), CLAMP(currColor.b + (m_colorVelocity.b * dt), 0.0f, 1.0f), CLAMP(currColor.a + (m_colorVelocity.a * dt), 0.0f, 1.0f)) ); } }