This question is mostly aimed at the Corona Staff as they’re the only ones who really know what goes under the hood and can give me a proper answer.
I was wondering what’s the best way to “deactivate” a Display Object without removing it completely. In other words, I would like to keep the object in memory, but tell Corona to do absolutely nothing with it for now, aka not draw it or give it ANY cpu time. At least until I activate it again.
Currently I am doing this:
[lua]object.isVisible = false
timer.performWithDelay(5, function() object.isBodyActive = false end) – Assuming it has a physical body. The timer is there since disabling the body immediately sometimes causes errors, especially during collisions
display.getCurrentStage():insert(object) – Remove it from its parent group, if it has one[/lua]
Then when I want to activate it again I do this:
[lua]object.isVisible = true
timer.performWithDelay(10, function() object.isBodyActive = true end)
parentGroup:insert(object)[/lua]
Am I doing it right, or is there a better way? And if I am, are all 3 actions necessary?
P.S.
It would be nice if Corona simply had a object:deactivate() method
