예제 #1
0
void GameScene::ballPopExplosion(Ball* ball, bool showScore)
{
    const char* color = ball->getBallColor();
    ccColor4F effectColor = GameUtils::getColor4F(color);
    ccColor3B textColor = GameUtils::getColor3B(color);

    CCParticleExplosion* popEffect = CCParticleExplosion::createWithTotalParticles(45);
    popEffect->setStartColor(effectColor);
    popEffect->setEndColor(effectColor);
    popEffect->setLife(0.075);
    popEffect->setPosition(ccp(ball->getX(), ball->getY()));
    this->addChild(popEffect);

    if (showScore) {
        char pointsEarnedArray[6];
        sprintf(pointsEarnedArray, "+%d", getPointsEarned());
        CCLabelTTF* pointsEarnedLabel = CCLabelTTF::create(
            pointsEarnedArray, "Marker Felt.ttf", POINTS_LABEL_FONT_SIZE);
        pointsEarnedLabel->setColor(textColor);
        pointsEarnedLabel->setPosition(ccp(ball->getX(), ball->getY()));
        this->addChild(pointsEarnedLabel, ZIndexGameTextLabels);

        CCAction* fadeOut = CCFadeOut::create(0.75);
        pointsEarnedLabel->runAction(fadeOut);
        pointsEarnedLabel = NULL;
    }
}
예제 #2
0
CCParticleExplosion* CCParticleExplosion::createWithTotalParticles(unsigned int numberOfParticles)
{
    CCParticleExplosion* pRet = new CCParticleExplosion();
    if (pRet && pRet->initWithTotalParticles(numberOfParticles))
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    return pRet;
}
예제 #3
0
CCParticleExplosion* CCParticleExplosion::create()
{
    CCParticleExplosion* pRet = new CCParticleExplosion();
    if (pRet && pRet->init())
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    return pRet;
}
예제 #4
0
KDvoid Level1Scene::ExplosionAnimation ( CCPoint tPos,const KDchar* szImgName )
{

	CCParticleExplosion* pEmitter = new CCParticleExplosion ( );
	pEmitter->setTexture(CCTextureCache::sharedTextureCache ( )->addImage ( szImgName ) );
	pEmitter->initWithTotalParticles ( 10 );      
	pEmitter->setStartSize ( 20.0f );
	pEmitter->setSpeed ( 50.0f );
	pEmitter->setAnchorPoint ( ccp ( 0.5f,0.5f ) );
	pEmitter->setPosition ( tPos );
	pEmitter->setDuration ( 0.5f );
	ccColor4F startColor = { 219.5f, 147.5f, 29.5f, 1.0f };
	pEmitter->setStartColor ( startColor );
	
	ccColor4F startColorVar = { 219.5f, 147.5f, 29.5f, 1.0f };
	pEmitter->setStartColorVar ( startColorVar );
	
	ccColor4F endColor = { 167.1f, 91.1f, 39.1f, 1.0f };
	pEmitter->setEndColor ( endColor );
	
	ccColor4F endColorVar = { 167.1f, 91.1f, 39.1f, 1.0f };    
	pEmitter->setEndColorVar ( endColorVar );
	pEmitter->setAutoRemoveOnFinish ( KD_TRUE );
	pEmitter->retain ( );
	addChild ( pEmitter, 1 );
	pEmitter->release ( );
}