Who can explain me this?
Destroy means remove from screen forever, you can still keep a reference to it in js.
That's what I thought, thanks Koen :)
So once you destroy you also need to clear your var. that confused me too initially.
Out of curiosity, how do you do that? I thought variables created using var (coffee way) can't be deleted/cleared.
layer = null
I guess I assume eventually it will get garbage collected.
Oh yeah, I knew that one :)
This would have helped me out so much like a year ago when Framer was brand new
This is smartly called "garbage collection", because it doesn't do it right away but once every x time. The upside is convenience for programmers like us, the downside that these garbage collection events are unpredictable and can cause animations to drop frames.
I had the garbage collection problem when I built SpaceInFramers. The ball would still collide with the target even after the object was destroyed. I worked around this by pushing the layers inside an array and then -> splice -> destroy to ensure the next ball couldn't reference the target that was destroyed after collision.