Basically, here is the trouble:
void ParticleGenerator::idleUpdate(){ for (it = particles.begin(); it != particles.end();it++) { (*it)->update(); if ((*it)->getTtl() < 0) { particles.erase(it); break; } }}
If I remove the "break" command, I get a weird error.. I suppose thats because the end of the list is not the same as it was when the loop started (given that I have one less element in there).
However, with the "break" command, particles start acting funny when the all start to get erased... they get too slow because I am constantly moving the iterator do the beginning of the list...
For sake of information, here is the non-idle update source (when a key is pressed, particles keep being added to the system.. actually, they are relocated to the origin position)
void ParticleGenerator::update(){ for (it = particles.begin(); it != particles.end();it++) { (*it)->update(); if ((*it)->getTtl() < 0) { (*it)->restartParticle(); } } addParticle();}
Anyone knows a way to solve this? I`m guessing that "break" does not belong there... not sure tho...
thanks