emitter delay and system deletion

This commit is contained in:
Henrique Santiago
2011-12-15 21:48:15 -02:00
parent 9a5be9c4d8
commit 435161df62
8 changed files with 125 additions and 26 deletions

View File

@@ -35,7 +35,7 @@ bool ParticleManager::load(const std::string& filename)
if(node->tag() == "ParticleSystem") {
ParticleSystemPtr particleSystem = ParticleSystemPtr(new ParticleSystem);
particleSystem->load(node);
m_particlesSystems.push_back(particleSystem);
m_particleSystems.push_back(particleSystem);
}
}
return true;
@@ -47,12 +47,21 @@ bool ParticleManager::load(const std::string& filename)
void ParticleManager::render()
{
for(auto it = m_particlesSystems.begin(), end = m_particlesSystems.end(); it != end; ++it)
for(auto it = m_particleSystems.begin(), end = m_particleSystems.end(); it != end; ++it)
(*it)->render();
}
void ParticleManager::update()
{
for(auto it = m_particlesSystems.begin(), end = m_particlesSystems.end(); it != end; ++it)
(*it)->update();
for(auto it = m_particleSystems.begin(), end = m_particleSystems.end(); it != end;) {
const ParticleSystemPtr& particleSystem = *it;
if(particleSystem->hasFinished()) {
it = m_particleSystems.erase(it);
continue;
}
particleSystem->update();
++it;
}
}