pixijs / particle-emitter

A particle system for PixiJS
http://pixijs.io/particle-emitter/docs
MIT License
793 stars 125 forks source link

When time is reversed an age drops below 0 the particle is killed #84

Closed st3v0 closed 6 years ago

st3v0 commented 6 years ago

When time is reversed weird behaviour is observed by the particles when the age drops below 0. Granted time should never be reversed however since the consumer of the library can manually control the update method it's possible for them to play time backwards. This is merely a safety catch so that when that does happen the particles whom's age shows they haven't been born yet are killed off. This stops the weird behaviour from occurring.

Once time returns to normal (ie. forward) then new particles are created in place of those that were killed during the reversal of time.

andrewstart commented 6 years ago

Thanks!

st3v0 commented 6 years ago

Hmm, I must have missed something somewhere. It looks like when time starts moving forward again (after reversing for a little bit) it takes a bit of time for new particles to start being created again. Maybe the reversal of time is affecting the spawn timer...

andrewstart commented 6 years ago

The Emitter has

//decrease spawn timer
this._spawnTimer -= delta;
//while _spawnTimer < 0, we have particles to spawn
while(this._spawnTimer <= 0)
{

so every time that a negative delta is used, it increases the time before the next particle spawns.