本文整理汇总了C++中CCParticleSystem类的典型用法代码示例。如果您正苦于以下问题:C++ CCParticleSystem类的具体用法?C++ CCParticleSystem怎么用?C++ CCParticleSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCParticleSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addParticleSystem
CCParticleSystem* ADParticleSystemCache::addParticleSystem( const char *pFileName )
{
CCParticleSystem *pRetPart = NULL;
ParticleSystemBatchMap::iterator iter = m_particleBatchesIdle.find( pFileName );
if( iter == m_particleBatchesIdle.end() )
{
pRetPart = CCParticleSystemQuad::create( pFileName );
CCParticleBatchNode *pNode = CCParticleBatchNode::createWithTexture( pRetPart->getTexture(), 100 );
m_pRootNode->addChild( pNode );
pNode->addChild( pRetPart );
m_particleBatchesUsed[pFileName]._pBatchNode = pNode;
m_particleBatchesIdle[pFileName]._pBatchNode = pNode;
}
else
{
if( iter->second._particleSystems.empty() )
{
pRetPart = _createNewParticleSystem( pFileName, iter->second._pBatchNode );
iter->second._particleSystems.push_back( pRetPart );
}
else
{
pRetPart = iter->second._particleSystems.front();
iter->second._particleSystems.pop_front();
}
}
CCAssert( pRetPart != NULL, " add particle system error " );
m_particleBatchesUsed[pFileName]._particleSystems.push_back( pRetPart );
return pRetPart;
}
示例2: CCAssert
// override removeChild:
void CCParticleBatchNode::removeChild(CCNode* child, bool cleanup)
{
// explicit nil handling
if (child == NULL)
{
return;
}
CCAssert( dynamic_cast<CCParticleSystem*>(child) != NULL, "CCParticleBatchNode only supports CCQuadParticleSystems as children");
CCAssert(m_pChildren->containsObject(child), "CCParticleBatchNode doesn't contain the sprite. Can't remove it");
CCParticleSystem* pChild = (CCParticleSystem*)child;
CCNode::removeChild(pChild, cleanup);
// remove child helper
m_pTextureAtlas->removeQuadsAtIndex(pChild->getAtlasIndex(), pChild->getTotalParticles());
// after memmove of data, empty the quads at the end of array
m_pTextureAtlas->fillWithEmptyQuadsFromIndex(m_pTextureAtlas->getTotalQuads(), pChild->getTotalParticles());
// particle could be reused for self rendering
pChild->setBatchNode(NULL);
updateAllAtlasIndexes();
}
示例3: CCPointMake
//------------------------------------------------------------------
//
// SchedulerTest
//
//------------------------------------------------------------------
void SchedulerTest::onEnter()
{
EaseSpriteDemo::onEnter();
// rotate and jump
CCActionInterval* jump1 = CCJumpBy::actionWithDuration(4, CCPointMake(-400,0), 100, 4);
CCActionInterval* jump2 = jump1->reverse();
CCActionInterval* rot1 = CCRotateBy::actionWithDuration(4, 360*2);
CCActionInterval* rot2 = rot1->reverse();
CCFiniteTimeAction* seq3_1 = CCSequence::actions(jump2, jump1, NULL);
CCFiniteTimeAction* seq3_2 = CCSequence::actions( rot1, rot2, NULL);
CCFiniteTimeAction* spawn = CCSpawn::actions(seq3_1, seq3_2, NULL);
CCFiniteTimeAction* action = CCRepeatForever::actionWithAction((CCActionInterval*)spawn);
CCRepeatForever* action2 = (CCRepeatForever*)(action->copy()->autorelease());
CCRepeatForever* action3 = (CCRepeatForever*)(action->copy()->autorelease());
m_grossini->runAction( CCSpeed::actionWithAction((CCActionInterval*)action, 0.5f) );
m_tamara->runAction( CCSpeed::actionWithAction((CCActionInterval*)action2, 1.5f) );
m_kathia->runAction( CCSpeed::actionWithAction((CCActionInterval*)action3, 1.0f) );
CCParticleSystem* emitter = CCParticleFireworks::node();
emitter->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
addChild(emitter);
//sliderCtl = [self sliderCtl];
//[[[[Director sharedDirector] openGLView] window] addSubview: sliderCtl];
}
示例4: switch
void Role::skillAction(SkillState sk){
switch (sk) {
case Skill_Blood:{
SimpleAudioEngine::sharedEngine()->playEffect(S_BLOOD);
CCParticleSystem* particle = CCParticleSystemQuad::create("Teleport.plist");
particle->setStartColor(ccc4f(0.5, 0.5, 0.5, 1));
particle->setPosition(this->getObjPosition());
GameLogic::Singleton()->getPView()->addChild(particle,99,Blood_Particle_Tag);
float bloodValue = GameLogic::Singleton()->getBlood();
GameLogic::Singleton()->setBlood(bloodValue += bloodValue * 0.1);//10%
CCLOG("+=================Blood Skill Open===============+");
}
break;
case Skill_Sprint:{
int deltaTime = 2.0f;
if (_skState == Skill_Sprint)
deltaTime += 2.0f;
else
_skState = Skill_Sprint;
this->setObjRotation(0);
SimpleAudioEngine::sharedEngine()->playEffect(S_SPRINT);
CCParticleSystem* particle = CCParticleSystemQuad::create("Sprint.plist");
particle->setPosition(ccpAdd(this->getObjPosition(),ccp(30,0)));
GameLogic::Singleton()->getPView()->addChild(particle,99,Sprint_Tag);
_standardPoint.x = 200;
this->runAction(CCSequence::create(CCDelayTime::create(deltaTime),
CCCallFuncND::create(this,callfuncND_selector(Role::sprintFunc),this),
NULL));
}
break;
case Skill_Wave:{
SimpleAudioEngine::sharedEngine()->playEffect(S_WAVE);
this->deleteObjectsInWave();
CCSprite* waveSpr = CCSprite::createWithSpriteFrameName("Wave.png");
waveSpr->setScale(0.1f);
waveSpr->setPosition(ccp(15, 15));
CCSpawn* spawnAction = CCSpawn::create(CCScaleTo::create(0.5f, 1.5f),
CCFadeOut::create(0.5f),
NULL);
CCSequence* sequceceAction = CCSequence::create(spawnAction,
CCCallFuncND::create(this, callfuncND_selector(Role::waveFunc),this),
NULL);
CCSpeed* aSpeed = CCSpeed::create(sequceceAction, 2.5f);
waveSpr->runAction(aSpeed);
this->addChild(waveSpr,99,Wave_Tag);
}
break;
default:
break;
}
}
示例5: CCParticleSystemQuad
CCParticleSystem* ParticleLayer::createPhoenix()
{
CCParticleSystem *emitter = new CCParticleSystemQuad();
emitter->initWithFile("Particles/Phoenix.plist");
addChild(emitter, 10);
return emitter;
}
示例6: createExplodingRing
void ParticleLayer::gravityShock(CCObject *pdata)
{
CCDictionary *dict = dynamic_cast<CCDictionary*>(pdata);
float x = dynamic_cast<CCFloat*>(dict->objectForKey("x"))->getValue();
float y = dynamic_cast<CCFloat*>(dict->objectForKey("y"))->getValue();
CCParticleSystem *emitter = createExplodingRing();
emitter->setPosition(ccp(x, y));
}
示例7: getChildByTag
void ParticleMainScene::step(float dt)
{
CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagLabelAtlas);
CCParticleSystem *emitter = (CCParticleSystem*) getChildByTag(kTagParticleSystem);
char str[10] = {0};
sprintf(str, "%4d", emitter->getParticleCount());
atlas->setString(str);
}
示例8: createFireParticle
CCParticleSystem* ParticleLayer::createFireParticle()
{
CCParticleSystem *emitter = CCParticleFire::create();
emitter->retain();
addChild(emitter, 10);
emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage("Particles/fire.png") );
return emitter;
}
示例9: CCPointMake
IntervalLayer::IntervalLayer()
{
m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f;
CCSize s = CCDirector::sharedDirector()->getWinSize();
// sun
CCParticleSystem* sun = CCParticleSun::node();
sun->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
sun->setPosition( CCPointMake(s.width-32,s.height-32) );
sun->setTotalParticles(130);
sun->setLife(0.6f);
this->addChild(sun);
// timers
m_label0 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
m_label1 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
m_label2 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
m_label3 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
m_label4 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
scheduleUpdate();
schedule(schedule_selector(IntervalLayer::step1));
schedule(schedule_selector(IntervalLayer::step2), 0);
schedule(schedule_selector(IntervalLayer::step3), 1.0f);
schedule(schedule_selector(IntervalLayer::step4), 2.0f);
m_label0->setPosition(CCPointMake(s.width*1/6, s.height/2));
m_label1->setPosition(CCPointMake(s.width*2/6, s.height/2));
m_label2->setPosition(CCPointMake(s.width*3/6, s.height/2));
m_label3->setPosition(CCPointMake(s.width*4/6, s.height/2));
m_label4->setPosition(CCPointMake(s.width*5/6, s.height/2));
addChild(m_label0);
addChild(m_label1);
addChild(m_label2);
addChild(m_label3);
addChild(m_label4);
// Sprite
CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini);
sprite->setPosition( CCPointMake(40,50) );
CCJumpBy* jump = CCJumpBy::actionWithDuration(3, CCPointMake(s.width-80,0), 50, 4);
addChild(sprite);
sprite->runAction( CCRepeatForever::actionWithAction(
(CCActionInterval*)(CCSequence::actions(jump, jump->reverse(), NULL ))
)
);
// pause button
CCMenuItem* item1 = CCMenuItemFont::itemFromString("Pause", this, menu_selector(IntervalLayer::onPause) );
CCMenu* menu = CCMenu::menuWithItems(item1, NULL);
menu->setPosition( CCPointMake(s.width/2, s.height-50) );
addChild( menu );
}
示例10: updateParticleDisplay
void CCDisplayFactory::updateParticleDisplay(CCBone *bone, CCNode *display, float dt, bool dirty)
{
CCParticleSystem *system = (CCParticleSystem *)display;
CCBaseData node;
CCTransformHelp::matrixToNode(bone->nodeToArmatureTransform(), node);
system->setPosition(node.x, node.y);
system->setScaleX(node.scaleX);
system->setScaleY(node.scaleY);
system->update(dt);
}
示例11: CS_DISPLAY_PARTICLE_UPDATE
void CS_DISPLAY_PARTICLE_UPDATE(Bone *bone, DecorativeDisplay *decoDisplay, float dt, bool dirty)
{
CCParticleSystem *system = (CCParticleSystem*)decoDisplay->getDisplay();
Node node;
TransformHelp::matrixToNode(bone->nodeToArmatureTransform(), node);
system->setPosition(node.x, node.y);
system->setScaleX(node.scaleX);
system->setScaleY(node.scaleY);
system->update(dt);
}
示例12: CCARRAY_FOREACH
//rebuild atlas indexes
void CCParticleBatchNode::updateAllAtlasIndexes()
{
CCObject *pObj = NULL;
unsigned int index = 0;
CCARRAY_FOREACH(m_pChildren,pObj)
{
CCParticleSystem* child = (CCParticleSystem*)pObj;
child->setAtlasIndex(index);
index += child->getTotalParticles();
}
示例13: CCParticleSystem
CCParticleSystem * CCParticleSystem::create(const char *plistFile)
{
CCParticleSystem *pRet = new CCParticleSystem();
if (pRet && pRet->initWithFile(plistFile))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return pRet;
}
示例14: createMeteor
CCParticleSystem* ParticleLayer::createMeteor()
{
CCParticleSystem *emitter = CCParticleMeteor::create();
emitter->retain();
addChild(emitter, 10);
emitter->setGravity(CCPointZero);
emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage("Particles/fire.png") );
return emitter;
}
示例15: initSpiral
void TestParticle::initSpiral()
{
CCParticleSystem *emitter = CCParticleSpiral::create();
emitter->retain();
addChild(emitter,10);
emitter->setTexture(CCTextureCache::sharedTextureCache()->addImage("fire.png"));
emitter->setPosition(ccp(250,50));
emitter->release();
}