Closed Adolio closed 3 years ago
Hi Aurélien!
That is a misunderstanding, yes — disposing a display object won't automatically remove it from its parent. Doing removal and disposal at the same time, that's what removeFromParent(true)
is for — just like you're calling it.
It's not far-fetched to think that it would remove it, though — it could have been implemented that way. I think the reason I didn't was just that I like to keep responsibilities separated – a method shouldn't do unexpected things, and the name dispose
doesn't say anything about removing an object from the display list. Doing it the other way around (removeFromParent(true)
) just seems more explicit to me.
Thanks Daniel for the fast & clear explanations!
That's clearer for me now 🙂
You're welcome, Aurélien! I'm glad I could help! 😄
Hi Daniel,
Maybe that's a misunderstanding from my side, I just discovered that the
DisplayObject::dispose()
method is not (always?) removing the object from its parent.I noticed that when disposing a
ParticleSystem
with aFilter
applied on it. CallingmyParticleSystemWithAFilter.dispose()
is causing the following error at next render pass:👉 However, when doing
myParticleSystemWithAFilter.removeFromParent(true)
instead, everything is fine 👍Is there any particular reason to keep a disposed
DisplayObject
attached to its parent (and therefore potentially in the render list)?Perhaps that's only an issue in the
Starling-Extension-Particle-System
extension?Thanks in advance for your help 🙂