Question

In my libgdx game want to draw an information panel where my current health and so on is displayed. I have seen this question which shows something similar, but my panel doesn't need to react on user Input, it should just display informations. Thats why i don't want to add a second stage to my gamescreen. But i need to be sure it is drawn in front of everything else. How can i manage that? I think the z-Index won't work, cause when my character shoots it adds a "Bullet" actor to the stage and this one would be at the last index right? The same thing would be with the "Pause Menu" but for this i really could use a second stage. Or is there also a better solution for the pause menu?

EDIT: Is it a good idea to override the stage.draw() method? I could call super.draw() first and then draw my infopanel. So it would be always in front. Or shouldn't i override stage.draw()?

Was it helpful?

Solution

The best way out here would be to HAVE 2 stages.

If you don't want it to react to user input interaction, the only thing you will need to do is not to set the second stage as inputprocessor.

Overriding stage.draw() would obviously work, but it would make it difficult to maintain. Moreover it'd be an undesirable design choice, since your game functionality is being described in a subclass of stage (it should be an actor (in an ideal world :D ) )

Hope this helps.

OTHER TIPS

Is it a good idea to override the stage.draw() method? I could call super.draw() first and then draw my infopanel. So it would be always in front. Or shouldn't i override stage.draw()?

If you really want all to be in one single stage. (I don't really see the point as using 2 stages would make the design easier). Then yes. Do not hesitate on overriding Stage.draw();

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