Gamua / Starling-Extension-Particle-System

A particle system for the Starling framework, compatible with the "Particle Designer" from 71squared.com
Other
323 stars 146 forks source link

Bug of Starling Extension - Particle System, it may not dispatch COMPLETE event #27

Closed tilergames closed 9 years ago

tilergames commented 9 years ago

The starling extension, particle system, it may not dispatch COMPLETE event on some circumstance.

Due to the code downhere in ParticleSystem.advanceTime :

                if (mNumParticles == 0 && mEmissionTime == 0)
                    dispatchEvent(new Event(Event.COMPLETE));

if the mEmissionTime member is not zero, the the event COMPLETE will be not disptached. but the mEmissionTime is minused after that code

So it may add code after the mEmissionTime change, like below,

            if (mEmissionTime != Number.MAX_VALUE)
                mEmissionTime = Math.max(0.0, mEmissionTime - passedTime);

            if (mNumParticles == 0 && mEmissionTime == 0)
                dispatchEvent(new Event(Event.COMPLETE));

I've tested the code, it works.

Thanks. Hope it help.

PrimaryFeather commented 9 years ago

Thanks a lot for the report and the fix! I'd love to be able to reproduce the problem myself, though, to be sure there are no side effects. Do you think you could send me a quick demo that shows the case when the event is not dispatched? (E.g. just a pex file and (if necessary) the code that causes COMPLETE not be dispatched.) That would be a huge help — thanks a lot in advance!

PrimaryFeather commented 9 years ago

Ah, forget it — I could reproduce the problem. Fixed in a9e58ed37145c8a9057a1109bb0a2b8564a17a93.

Thanks again for the report!