How to stop CCParticleSystem effect in touches ended.....


#1

Hi,

In touches Began i have added particle effect Example….

void FindMamaGamePlay::ccTouchesBegan(CCSet* touches, CCEvent* event)
{
CCTouch* touch = (CCTouch**)touches~~>anyObject;
CCPoint touchPoint = touch~~>getLocationInView;
touchPoint = CCDirector::sharedDirector~~>convertToGL;
//Create Particle Effect
CCParticleSystem * addParticleEffectToTexture = CCParticleSystemQuad::create;
addParticleEffectToTexture~~>setPosition;
this~~>animalLayer~~>addChild;
CCObject** ChildSpriteObj = NULL;
}

Please anyone reply me how to stop this effect in ccTouchesEnded……


#2

You should keep a pointer to this particle effect, or at least assign a tag to it with

addParticleEffectToTexture->setTag(SOME_MEANINGFUL_INTEGER);

Then in the ccTouchesEnded method you can simply remove this effect like that :

//if you stored a pointer
this->animalLayer->removeChild(POINTER_TO_PARTICLE_EFFECT);
//or if you added a tag to it
this->animalLayer->removeChild(this->animalLayer->getChildByTag(THE_SAME_MEANINGFUL_INTEGER));

#3

removeChildByTag
http://www.cocos2d-x.org/embedded/cocos2d-x/d0/ded/classcocos2d_1_1_c_c_node.html#a7ec322eb5ecf0c415748dd58ce95cab3