aspect2d detach children

Hi.

I’m struggle with strange result concerning aspect2d.

I’m trying to change the interface. The goal is to put the application on pause, the interface disappear and reappear after the pause.

pause

self.aspect_saved = aspect2d.getChildren()
aspect2d.getChildren().detach()

un-pause

self.aspect_saved.reparentTo(aspect2d)

here’s the strange result: when I pause, everything stay put.
When I unpause, most of the interface disappeared and/or stay in broken state ( buttons not working anymore but still here, labels completely disappears.)

I am missing something somewhere ?

First guess is, when you pause, you also stop rendering frames, so that you don’t get a chance to see the controls actually disappear.

Second guess is, when you reparentTo(aspect2d), it doesn’t put everything back in the same order (it’s not guaranteed to do this), so some labels are now below their frames and so on. Consider using hide() and show() instead.

David

I’m still rendering frame, so it’s not that.
unless the rendering in 2d need something particular to ‘know’ that a node is no longer here ?

For the re parenting, it’s more probable. I will see that I can do. fact, is I need 2 node at different time ( one in pause, and one in un-pause)
When I change I want to un parent all that has been created, and re parent what been created in the other ‘mode’, and vice versa.

Nothing special about aspect2d. If you’re really rendering frames, and you’re seeing stuff onscreen, then there really is stuff onscreen. If you think you’ve removed everything and you’re still seeing stuff onscreen, then you must be mistaken. Perhaps there is some stuff you’re seeing under render2d, for instance; or perhaps your code to remove stuff isn’t actually getting called, or the code that puts it back is getting called sooner than you think.

David

I, by myself, create self.interfaceFrame = DirectFrame… and the interface elements I reparentTo(self.interfaceFrame) or use parent = self.interfaceFrame, then I use .show() when un-pause and .hide() when pause. That’s quite simple.

I hope it helps you.