Problem with CCParticleSystemQuad

Problem with CCParticleSystemQuad
0.0 0


I’ve found an interesting problem with CCParticleSystemQuad initialized from a plist file. This problem’s appeard since the last version update I think. My particles easily dissappeared. I’ve tried every possible solution but no particles were shown. Then when I use the particles from the example class (fire or fireworks), they worked well. At last I found out that the problem was with the setting up the texture. When I used the line:

my system begun to work again! When the particle is inited from the plist, there is only m_pTexture = tex;, but setTexture call is missing. CCParticleSystemQuad version of setTexture do several things except the m_pTexture initialization~~ mainly it set up the texture rectangle! This is the reason why my particle system did not work.

Can you tell me, where was the problem?

I solved it by adding setTexture() instead of m_pTexture = tex and remove the retain() call on the texture in the init method (retain is also called in the setTexture()).

Thanks a lot for help.


Sorry, could you paste a code snip to reproduce this bug? I read your post but a bit dizzy about how to reproduce it.


Yes, I can, but it is pretty simple:) Firstly, I don’t think that is a bug. Actually, I do not know what is it :)
I will do some example during the tomorrow.

Thanks for the engine.


I have just created particle system:

m_left = CCParticleSystemQuad::particleWithFile(“someparticle.plist”);
addChild(m_left, 1);

This particle system is not visible for me. The system is under another CCNode descendant.

Then I found out that CCParticleSystem::initWithDictionary() does not call setTexture() but only inits m_pTexture on line 285. It was problem for me, because setTextureWithRect() and initTexCoordsWithRect() methods are not called. So the texture was set correctly but the rectangles for particles not.

Hope this helps…


Could you share the plist too please? I’ve encountered similar problems, plus crashing. I have no idea why did it work after some time hacking around.


Yes, sure, but I tried to modify it and the situation was the same.


Hey you’re not Czech by any chance?

Follow this “snippet”, ever since I’ve been using this it never crashed on me:

//Snippet for particle as background for sprite CCSprite *sprite = CCSprite::spriteWithFile("sprite.png", CCRectMake(0,0,spritex,spritey) ); CCParticleSystem* particle; // You can use this to test if you don't have a particle ready // particle = CCParticleFire::node(); particle = new CCParticleSystemQuad; particle->retain(); particle->initWithFile("particle.plist"); //Set up an alternative texture if you want to // CCTexture2D* tex = CCTextureCache::sharedTextureCache()->addImage("texture.png"); // particle->setTexture(tex); //Make sure it rests at the right place, always, no matter what size, no matter what sprite texture is the parent particle->setPosition(ccp(sprite->getContentSizeInPixels().height/2*sprite->getScale(),sprite->getContentSizeInPixels().width/2*sprite->getScale())); //Make sure it's always as big as we want it to, counting that you have a power of 2 sprite as the parent asfire->setStartSize(target->getContentSizeInPixels().height); //Set up parameters you want asfire->setPosVar(ccp(2,2)); asfire->setAngleVar(12); asfire->setGravity(ccp(0,255)); asfire->setIsBlendAdditive(true); //Add as child, you could use sprite->getZOrder()-1 if you want to sprite->addChild(asfire, -1);


Thanks for this post.
So does this mean the normal way to create / initialize such a particle system has a code issue ?

Normally we won’t manually create a bare bone object like this. Please advice. Thanks !


Sorry I have no idea.