コード例 #1
0
void Tutorial::Crash()// draws the animation for a crash and pasticles that fly out from there
{
	//animation code
	auto spritecache = SpriteFrameCache::getInstance();
	spritecache->addSpriteFramesWithFile("GameScreen/explosion.plist");
	cocos2d::SpriteFrame* spriteFrame = spritecache->getSpriteFrameByName("explosion0.png");
	cocos2d::Vector<cocos2d::Sprite *> m_aiSprites;
	cocos2d::Vector<cocos2d::SpriteFrame*> m_animFrames;
	for (int i = 0; i < 23; i++)
	{
		// Get a SpriteFrame using a name from the spritesheet .plist file.
		m_animFrames.pushBack(spritecache->getSpriteFrameByName("explosion" + std::to_string(i) + ".png"));
	}
	// Create the animation out of the frames.
	Animation* animation = Animation::createWithSpriteFrames(m_animFrames, 0.065);
	Animate* animate = Animate::create(animation);
	// Create a sprite using any one of the SpriteFrames
	// This is so we get a sprite of the correct dimensions.
	auto sprite = Sprite::createWithSpriteFrame(m_animFrames.at(0));
	// Run and repeat the animation.
	sprite->setScale(3.0f);
	sprite->runAction(RepeatForever::create(animate));
	sprite->setPosition(Vec2(player->getPosition().x, player->getPosition().y - 5));
	this->addChild(sprite, 10);
	m_aiSprites.pushBack(sprite);


	//code for the particles that will be coloured orange
	auto size = Director::getInstance()->getWinSize();
	auto m_emitter = ParticleExplosion::createWithTotalParticles(900);
	m_emitter->setDuration(-1);
	m_emitter->setGravity(Point(0, -240));
	m_emitter->setAngle(0);
	m_emitter->setAngleVar(180);
	m_emitter->setRadialAccel(25);
	m_emitter->setRadialAccelVar(0);
	m_emitter->setTangentialAccel(10);
	m_emitter->setTangentialAccelVar(0);
	m_emitter->setPosVar(Point(1, 0));
	m_emitter->setLife(0.25);
	m_emitter->setLifeVar(0.50);
	m_emitter->setStartSpin(0);
	m_emitter->setStartSpinVar(0);
	m_emitter->setEndSpin(0);
	m_emitter->setEndSpinVar(0);
	m_emitter->setStartColor(Color4F(212, 73, 0, 1));
	m_emitter->setStartColorVar(Color4F(0, 0, 0, 0));
	m_emitter->setEndColor(Color4F(212, 73, 0, 1));
	m_emitter->setEndColorVar(Color4F(0, 0, 0, 0));
	m_emitter->setStartSize(20.0f);
	m_emitter->setStartSizeVar(0);
	m_emitter->setEndSize(15.0f);
	m_emitter->setEndSizeVar(0);
	m_emitter->setEmissionRate(275);
	m_emitter->setPosition(Vec2(player->getPosition().x, player->getPosition().y - 15));
	addChild(m_emitter, 10);
}
コード例 #2
0
void ParticlePerformTest4::doTest()
{
    auto s = Director::getInstance()->getWinSize();
    auto particleSystem = (ParticleSystem*) getChildByTag(kTagParticleSystem);

    // duration
    particleSystem->setDuration(-1);

    // gravity
    particleSystem->setGravity(Vec2(0,-90));

    // angle
    particleSystem->setAngle(90);
    particleSystem->setAngleVar(0);

    // radial
    particleSystem->setRadialAccel(0);
    particleSystem->setRadialAccelVar(0);

    // speed of particles
    particleSystem->setSpeed(180);
    particleSystem->setSpeedVar(50);

    // emitter position
    particleSystem->setPosition(Vec2(s.width/2, 100));
    particleSystem->setPosVar(Vec2(s.width/2,0));

    // life of particles
    particleSystem->setLife(2.0f);
    particleSystem->setLifeVar(1);

    // emits per frame
    particleSystem->setEmissionRate(particleSystem->getTotalParticles() / particleSystem->getLife());

    // color of particles
    Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f);
    particleSystem->setStartColor(startColor);

    Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f);
    particleSystem->setStartColorVar(startColorVar);

    Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f);
    particleSystem->setEndColor(endColor);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f);   
    particleSystem->setEndColorVar(endColorVar);

    // size, in pixels
    particleSystem->setEndSize(64.0f);
    particleSystem->setStartSize(64.0f);
    particleSystem->setEndSizeVar(0);
    particleSystem->setStartSizeVar(0);

    // additive
    particleSystem->setBlendAdditive(false);

}
コード例 #3
0
ファイル: CCParticleExamples.cpp プロジェクト: 0x0c/cocos2d-x
bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
{
    if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
    {
        // duration
        _duration = DURATION_INFINITY;

        // Emitter mode: Gravity Mode
        setEmitterMode(Mode::GRAVITY);

        // Gravity Mode: gravity
        setGravity(Point(0,0));

        // Gravity Mode: radial acceleration
        setRadialAccel(0);
        setRadialAccelVar(0);

        // Gravity Mode: speed of particles
        setSpeed(25);
        setSpeedVar(10);

        // angle
        _angle = 90;
        _angleVar = 5;

        // emitter position
        Size winSize = Director::getInstance()->getWinSize();
        this->setPosition(Point(winSize.width/2, 0));
        setPosVar(Point(20, 0));

        // life of particles
        _life = 4;
        _lifeVar = 1;

        // size, in pixels
        _startSize = 60.0f;
        _startSizeVar = 10.0f;
        _endSize = START_SIZE_EQUAL_TO_END_SIZE;

        // emits per frame
        _emissionRate = _totalParticles/_life;

        // color of particles
        _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;

        Texture2D* texture = getDefaultTexture();
        if (texture != NULL)
        {
            setTexture(texture);
        }

        // additive
        this->setBlendAdditive(false);
        return true;
    }
    return false;
}
コード例 #4
0
ファイル: CCParticleExamples.cpp プロジェクト: 0x0c/cocos2d-x
bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
{
    if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) 
    {
        // duration
        _duration = 0.1f;

        setEmitterMode(Mode::GRAVITY);

        // Gravity Mode: gravity
        setGravity(Point(0,0));

        // Gravity Mode: speed of particles
        setSpeed(70);
        setSpeedVar(40);

        // Gravity Mode: radial
        setRadialAccel(0);
        setRadialAccelVar(0);

        // Gravity Mode: tangential
        setTangentialAccel(0);
        setTangentialAccelVar(0);

        // angle
        _angle = 90;
        _angleVar = 360;

        // emitter position
        Size winSize = Director::getInstance()->getWinSize();
        this->setPosition(Point(winSize.width/2, winSize.height/2));
        setPosVar(Point::ZERO);

        // life of particles
        _life = 5.0f;
        _lifeVar = 2;

        // size, in pixels
        _startSize = 15.0f;
        _startSizeVar = 10.0f;
        _endSize = START_SIZE_EQUAL_TO_END_SIZE;

        // emits per second
        _emissionRate = _totalParticles/_duration;

        // color of particles
        _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;

        Texture2D* texture = getDefaultTexture();
        if (texture != NULL)
        {
            setTexture(texture);
        }

        // additive
        this->setBlendAdditive(false);
        return true;
    }
    return false;
}
コード例 #5
0
ファイル: TestScene.cpp プロジェクト: dgkae/triplequest
void TestScene::emit()
{
    auto _emitter = ParticleSystemQuad::createWithTotalParticles(100);
    addChild(_emitter, 10);

    _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
    _emitter->setDuration(1.f);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // angle
    _emitter->setAngle(90);
    _emitter->setAngleVar(0);

    // speed of particles
    _emitter->setSpeed(260);
    _emitter->setSpeedVar(0);

    // radial
    _emitter->setRadialAccel(-260);
    _emitter->setRadialAccelVar(0);

    // tagential
    _emitter->setTangentialAccel(00);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    //    _emitter->setPosition( Vec2(160,240) );
    _emitter->setPosVar({2,10});

    // life of particles
    _emitter->setLife(1);
    _emitter->setLifeVar(0);

    // spin of particles
    _emitter->setStartSpin(10000);
    _emitter->setStartSizeVar(360);
    _emitter->setEndSpin(0);
    _emitter->setEndSpinVar(360);

    // color of particles
    Color4F startColor(0.f, 0.5f, 0.f, 1.0f);
    _emitter->setStartColor(startColor);

    Color4F startColorVar(0.f, 0.1f, 0.f, 1.0f);
    _emitter->setStartColorVar(startColorVar);

    Color4F endColor(0.1f, 0.5f, 0.1f, 1.0f);
    _emitter->setEndColor(endColor);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f);
    _emitter->setEndColorVar(endColorVar);

    // size, in pixels
    _emitter->setStartSize(5.0f);
    _emitter->setStartSizeVar(1.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive
    _emitter->setBlendAdditive(true);
    //addChild(_emitter);
    _emitter->setPosition(genPos({0.5,0.5}));
    //    _emitter->runAction(RotateBy::create(10.f, 1000));
}
コード例 #6
0
ファイル: CCParticleExamples.cpp プロジェクト: fordream/quick
bool CCParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
{
    if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
    {
        // duration
        m_fDuration = kCCParticleDurationInfinity;

        // Emitter mode: Gravity Mode
        setEmitterMode(kCCParticleModeGravity);

        // Gravity Mode: gravity
        setGravity(ccp(0,0));

        // Gravity Mode: radial acceleration
        setRadialAccel(0);
        setRadialAccelVar(0);

        // Gravity Mode: speed of particles
        setSpeed(25);
        setSpeedVar(10);

        // angle
        m_fAngle = 90;
        m_fAngleVar = 5;

        // emitter position
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        this->setPosition(ccp(winSize.width/2, 0));
        setPosVar(ccp(20, 0));

        // 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;

        CCTexture2D* pTexture = getDefaultTexture();
        if (pTexture != NULL)
        {
            setTexture(pTexture);
        }

        // additive
        this->setBlendAdditive(false);
        return true;
    }
    return false;
}
コード例 #7
0
ファイル: CCParticleExamples.cpp プロジェクト: fordream/quick
bool CCParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
{
    if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) 
    {
        // duration
        m_fDuration = 0.1f;

        setEmitterMode(kCCParticleModeGravity);

        // Gravity Mode: gravity
        setGravity(ccp(0,0));

        // Gravity Mode: speed of particles
        setSpeed(70);
        setSpeedVar(40);

        // Gravity Mode: radial
        setRadialAccel(0);
        setRadialAccelVar(0);

        // Gravity Mode: tangential
        setTangentialAccel(0);
        setTangentialAccelVar(0);

        // angle
        m_fAngle = 90;
        m_fAngleVar = 360;

        // emitter position
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        this->setPosition(ccp(winSize.width/2, winSize.height/2));
        setPosVar(CCPointZero);

        // 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;

        CCTexture2D* pTexture = getDefaultTexture();
        if (pTexture != NULL)
        {
            setTexture(pTexture);
        }

        // additive
        this->setBlendAdditive(false);
        return true;
    }
    return false;
}
コード例 #8
0
bool ParticleHitEmitter::initWithTotalParticles(unsigned int numberOfPartiles)
{
	if (CCParticleSystemQuad::initWithTotalParticles(numberOfPartiles))
	{
		// duration
		m_fDuration = 0.1f;

		setEmitterMode(kCCParticleModeGravity);

		// Gravity Mode: gravity
		setGravity(ccp(0, 0));

		// Gravity Mode: speed of particles
		setSpeed(0);
		setSpeedVar(0);

		// Gravity Mode: radial
		setRadialAccel(0);
		setRadialAccelVar(0);

		// Gravity Mode: tangential
		setTangentialAccel(0);
		setTangentialAccelVar(0);

		// angle
		m_fAngle = 90;
		m_fAngleVar = 360;

		// emitter position
		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		this->setPosition(ccp(winSize.width / 2, winSize.height / 2));
		setPosVar(CCPointZero);

		// life of particles
		m_fLife = 0.1f;
		m_fLifeVar = 0;

		// size, in pixels
		m_fStartSize = 100;
		m_fStartSizeVar = 0.0f;
		m_fEndSize = 300;

		// emits per second
		m_fEmissionRate = m_uTotalParticles / m_fDuration;
		//m_uTotalParticles = 50;
		// 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;

		setTexture(CCTextureCache::sharedTextureCache()->addImage("./Data/fire.png"));//.pvr");

		// additive
		this->setBlendAdditive(true);
		mLayer->addChild(this);
		return true;
	}
	return false;
}
コード例 #9
0
void FloatingEffectManager::toast_cure(const cocos2d::Vec2& srcPos, const cocos2d::Vec2& desPos, DDElementType elementType, int level)
{

    const float speed = 300;
    float len = (desPos-srcPos).length();
    if (len == 0) {
        return;
    }
    auto _emitter = ParticleSystemQuad::createWithTotalParticles(500);
    _emitter->setAutoRemoveOnFinish(true);
    _layer->addChild(_emitter, 10);

    _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
    _emitter->setDuration(len/speed);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // angle
    _emitter->setAngle(vector2angel(desPos-srcPos));
    _emitter->setAngleVar(0.5f* std::atan(DDConfig::battleCubeWidth()/len) * 180.f/3.1415926f);

    // speed of particles
    _emitter->setSpeed(speed);
    _emitter->setSpeedVar(0);

    // radial
    _emitter->setRadialAccel(-(speed/(2*len/speed)));
    _emitter->setRadialAccelVar(0);

    // tagential
    _emitter->setTangentialAccel(00);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    //    _emitter->setPosition( Vec2(160,240) );
    _emitter->setPosVar({0,0});

    // life of particles
    _emitter->setLife(2*len/speed);
    _emitter->setLifeVar(0);

    // spin of particles
    _emitter->setStartSpin(720);
    _emitter->setStartSizeVar(360);
    _emitter->setEndSpin(0);
    _emitter->setEndSpinVar(360);

    // color of particles
    Color4F startColor(0.f, 0.5f, 0.f, 0.8f);
    _emitter->setStartColor(startColor);

    Color4F startColorVar(0.f, 0.1f, 0.f, 0.1f);
    _emitter->setStartColorVar(startColorVar);

    Color4F endColor(0.1f, 0.5f, 0.1f, 0.8f);
    _emitter->setEndColor(endColor);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.1f);
    _emitter->setEndColorVar(endColorVar);

    // size, in pixels
    _emitter->setStartSize(3.0f);
    _emitter->setStartSizeVar(1.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive
    _emitter->setBlendAdditive(true);

    _emitter->setPosition(srcPos);
}
コード例 #10
0
void FloatingEffectManager::toast_help_tail(const cocos2d::Vec2& srcPos, const cocos2d::Vec2& desPos, const cocos2d::Color4F& color)
{
    const float time = 0.2;
    float len = (desPos-srcPos).length();
    if (len == 0) {
        return;
    }

    const float speed = len/time;
    auto _emitter = ParticleSystemQuad::createWithTotalParticles(500);
    _emitter->setAutoRemoveOnFinish(true);
    _layer->addChild(_emitter, 10);

    _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
    _emitter->setDuration(time*5);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // angle
    _emitter->setAngle(vector2angel(srcPos-desPos));
    _emitter->setAngleVar(3);

    // speed of particles
    _emitter->setSpeed(speed/5);
    _emitter->setSpeedVar(0);

    // radial
    _emitter->setRadialAccel(0);
    _emitter->setRadialAccelVar(0);

    // tagential
    _emitter->setTangentialAccel(0);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    //    _emitter->setPosition( Vec2(160,240) );
    _emitter->setPosVar({0,0});

    // life of particles
    _emitter->setLife(0.2);
    _emitter->setLifeVar(0);

    // spin of particles
    _emitter->setStartSpin(720);
    _emitter->setStartSizeVar(360);
    _emitter->setEndSpin(0);
    _emitter->setEndSpinVar(360);

    // color of particles
    _emitter->setStartColor(color);

    Color4F startColorVar(0.f, 0.1f, 0.f, 0.1f);
    _emitter->setStartColorVar(startColorVar);

    _emitter->setEndColor(color);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.1f);
    _emitter->setEndColorVar(endColorVar);

    // size, in pixels
    _emitter->setStartSize(2.0f);
    _emitter->setStartSizeVar(1.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive
    _emitter->setBlendAdditive(true);
    
    _emitter->setPosition(srcPos);
    _emitter->runAction(MoveTo::create(0.1, desPos));
}
コード例 #11
0
KDbool CCParticleSnow::initWithTotalParticles ( KDuint uNumberOfParticles )
{
	if ( CCParticleSystemQuad::initWithTotalParticles ( uNumberOfParticles ) ) 
	{
		// duration
		m_fDuration = kCCParticleDurationInfinity;

		// set gravity mode.
		setEmitterMode ( kCCParticleModeGravity );

		// Gravity Mode: gravity
		setGravity ( ccp ( 0, -1 ) );

		// Gravity Mode: speed of particles
		setSpeed ( 5 );
		setSpeedVar ( 1 );

		// Gravity Mode: radial
		setRadialAccel ( 0 );
		setRadialAccelVar ( 1 );

		// Gravity mode: tangential
		setTangentialAccel ( 0 );
		setTangentialAccelVar ( 1 );

		// emitter position
		const CCSize&  tWinSize = CCDirector::sharedDirector ( )->getWinSize ( );
		this->setPosition ( ccp ( tWinSize.cx / 2, tWinSize.cy + 10 ) );
		setPosVar ( ccp ( tWinSize.cx / 2, 0 ) );

		// 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;

		CCTexture2D*  pTexture = getDefaultTexture ( );
        if ( pTexture )
        {
            setTexture ( pTexture );
        }

		// additive
		this->setBlendAdditive ( KD_FALSE );
		return KD_TRUE;
	}
	return KD_FALSE;
}
コード例 #12
0
KDbool CCParticleMeteor::initWithTotalParticles ( KDuint uNumberOfParticles )
{
	if ( CCParticleSystemQuad::initWithTotalParticles ( uNumberOfParticles ) )
	{
		// duration
		m_fDuration = kCCParticleDurationInfinity;

		// Gravity Mode
		setEmitterMode ( kCCParticleModeGravity );

		// Gravity Mode: gravity
		setGravity ( ccp ( -200, 200 ) );

		// Gravity Mode: speed of particles
		setSpeed ( 15 );
		setSpeedVar ( 5 );

		// Gravity Mode: radial
		setRadialAccel ( 0 );
		setRadialAccelVar ( 0 );

		// Gravity Mode: tangential
		setTangentialAccel ( 0 );
		setTangentialAccelVar ( 0 );

		// angle
		m_fAngle = 90;
		m_fAngleVar = 360;

		// emitter position
		const CCSize&  tWinSize = CCDirector::sharedDirector ( )->getWinSize ( );
		this->setPosition ( ccpMid ( tWinSize ) );
		setPosVar ( CCPointZero );

		// 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;

		CCTexture2D*  pTexture = getDefaultTexture ( );
        if ( pTexture )
        {
            setTexture ( pTexture );
        }

		// additive
		this->setBlendAdditive ( KD_TRUE );
		return KD_TRUE;
	}
	return KD_FALSE;
}
コード例 #13
0
ファイル: BaseScene.cpp プロジェクト: Ratel13/arkaflow
void BaseScene::putEmitter3(Vec2 pos){
	m_emitterCreated ++;

	auto _emitter = ParticleSystemQuad::createWithTotalParticles(20);
    //_emitter->retain();
	_emitter->setTag(m_emitterCreated);

    this->addChild(_emitter, 10000);
    ////_emitter->release();    // win32 : Remove this line
    _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage("ui/ball_outer.png") );

	_emitter->setAngleVar(360);

    // duration
    _emitter->setDuration(-1);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // speed of particles
    _emitter->setSpeed(320);
    _emitter->setSpeedVar(80);

    // radial
    _emitter->setRadialAccel(-30);
    _emitter->setRadialAccelVar(-10);

    // tagential
    _emitter->setTangentialAccel(30);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    _emitter->setPosition(pos);
    _emitter->setPosVar(Vec2::ZERO);

    // life of particles
    _emitter->setLife(1.6f);
    _emitter->setLifeVar(0.8f);

    // color of particles
	_emitter->setStartColor(C4F_(E::P.C500, 0.4f));
    _emitter->setStartColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.3f));
    _emitter->setEndColor(C4F_(E::P.C300, 0.3f));
    _emitter->setEndColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.2f));

    // size, in pixels
    _emitter->setStartSize(32.0f);
    _emitter->setStartSizeVar(8.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive

    _emitter->setBlendAdditive(false);
	auto cbStopEmitter = CallFunc::create([this](){m_emitterStopped++; ((ParticleSystemQuad*)this->getChildByTag(m_emitterStopped))->stopSystem();});
	auto cbRemoveEmitter = CallFunc::create([this](){m_emitterReleased++; this->getChildByTag(m_emitterReleased)->removeFromParentAndCleanup(true);});
	_emitter->runAction(Sequence::create(DelayTime::create(0.3f), cbStopEmitter, DelayTime::create(2.0f), cbRemoveEmitter, nullptr));

}
コード例 #14
0
bool ParticleSpiral::initWithTotalParticles(int numberOfParticles)
{
    if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
    {
        // duration
        _duration = DURATION_INFINITY;

        // Gravity Mode
        setEmitterMode(Mode::GRAVITY);

        // Gravity Mode: gravity
        setGravity(Vec2(0,0));

        // Gravity Mode: speed of particles
        setSpeed(150);
        setSpeedVar(0);

        // Gravity Mode: radial
        setRadialAccel(-380);
        setRadialAccelVar(0);

        // Gravity Mode: tangential
        setTangentialAccel(45);
        setTangentialAccelVar(0);

        // angle
        _angle = 90;
        _angleVar = 0;

        // emitter position
        Size winSize = Director::getInstance()->getWinSize();
        this->setPosition(winSize.width/2, winSize.height/2);
        setPosVar(Vec2::ZERO);

        // life of particles
        _life = 12;
        _lifeVar = 0;

        // size, in pixels
        _startSize = 20.0f;
        _startSizeVar = 0.0f;
        _endSize = START_SIZE_EQUAL_TO_END_SIZE;

        // emits per second
        _emissionRate = _totalParticles/_life;

        // color of particles
        _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;

        Texture2D* texture = getDefaultTexture();
        if (texture != nullptr)
        {
            setTexture(texture);
        }

        // additive
        this->setBlendAdditive(false);
        return true;
    }
    return false;
}