0

I am working in cocos2d-x for last two weeks.I have made one game in cocos2d-iphone. Now i am trying to make the same that from android devices using cocos2d-x. I am using particle system when player will collect the stars. When player is collecting a star for the first time, the particle system is not getting display. After that for every star collection it gets visible. I have check that it is executing the function which is used for displaying particle system.

Code for adding particle system is:

CCParticleSystemQuad *system = CCParticleSystemQuad::create("stars.plist"); system->setTexture(CCTextureCache::sharedTextureCache()->addImage("stern.png")); system->setPosition(starSprite->getPosition().x, starSprite->getPosition().y); system->setLife(2); system->setLifeVar(2); system->setAutoRemoveOnFinish(true); this->addChild(system,2); 

Does anyone tell me why this is happening?

2
  • put a break point in CCParticleSystem::update and make sure it is getting called, you may have an issue with the scheduling / descheduling of update... Commented Aug 28, 2013 at 7:20
  • I pasted the same code and it worked fine. Are you sure the same code is getting called as "jonynz" mentioned ? Can you please mention your cocos2d-x version. Commented Jan 29, 2014 at 10:36

1 Answer 1

1

Use this code once to define your particlesystem, declare "system" in h file so you can use it later in cpp file.

CCParticleSystemQuad *system = CCParticleSystemQuad::create("stars.plist"); system->setTexture(CCTextureCache::sharedTextureCache()->addImage("stern.png")); system->setPosition(starSprite->getPosition().x, starSprite->getPosition().y); system->setLife(2); system->setLifeVar(2); system->stopSystem(); this->addChild(system,2); 

now when u collect star just put this line

system->resetSystem();

each time you collect star the particle system will be reset and displayed :)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.