How can i do a fixed sprite that don't move with my camera (for example: a life bar in the left up corner)?
I have already tried to do this in the hard way and i would like to see if there is a simple way to do this.
Is there a simple way to do that or i need to do this in relative to the player position?
And i am sorry for my broken english, I would be very grateful to those who answer me.
thankyou.
Usually for the task of UI you would use an extra scene2d Stage
and implement custom subclasses Actor
which you add to the Stage
and set their fixed position via Actor.setPosition()
. There are already several predefined UI elements in the scene2d.ui package. To simulate a healthbar you could either use a ProgressBar
, or you implement your own HealthBar extends Actor
, which renders a Sprite
of your choice.
The stage is stationary by default and has its own Camera
. As long as you do not manipulate that camera anyhow, you can just draw the stage with all elements via stage.draw()
and it will always remain at the same place (what you would expect from an ingame HUD).
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句