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

possible memory leak #21

Closed qgewfg closed 10 years ago

qgewfg commented 10 years ago

change the event that will be dispatched when emission of particles is finished from "COMPLETE" to "REMOVE_FROM_JUGGLER".

if someone wrote Starling.juggler.add(mParticleSystem); but didn't remove manually like this Starling.juggler.remove(mParticleSystem); that will cause memory leak.

and other objects that can be added to juggler are not require remove manually.

PrimaryFeather commented 10 years ago

Hi Justin, first of all: sorry for the late reply! You reached me in a busy time. ;-)

Actually, I don't think it's a good idea to make it like this. The problem is that in many situations, people are re-using their particle systems. E.g. you create an explosion PS and keep it on the screen, simply restarting it when an explosion happens. Somebody who uses this approach doesn't want to have the PS be removed from the juggler all the time.

I know I'm doing this with Tweens, but they are a little different: they are small, lightweight objects, not supposed to be reused. You create a tween only once and then forget about it.

So, in your case, you should simply listen to the COMPLETE event and manually remove it from the juggler when it's called.

I hope you're okay with that and I could explain my reasoning well enough! :-)