Question

Right now, I have bodies, Labels, and TextButtons in my Box2D world. The problem is that the labels and buttons show up in a table after the bodies are already placed in the world and when they show up, the bodies are on top of them and then you can't see the labels and buttons. How can I make the labels and buttons appear on top of the bodies? I can display code upon request.

Was it helpful?

Solution

I guess you mean the buttons and labels of your game HUD or user-interface which always should be rendered on top of the bodies and actors?

A box2d body itself doesn't have a texture/actor/image or whatever, unless you connect it... And I hope you're not connecting your labels etc with the bodies, only if you actually want the buttons to behave physically... ;)

So if you just want to always render the buttons etc on top of the whole scene just use a second Stage (or a second SpriteBatch) that calls its draw() method after the scene and bodies has been rendered... This way, they will always be on top of everything else and you can use a different coordinate system for scene and HUD...

Hope it helps...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top