LibGdx How to program the HP panel?

I am currently trying to program a game using LibGdx. I have a lot of structural part of my game, and now I'm trying to return the player information about the game to the player. The simplest concept for my user interface that I can think of is the HP bars and cartridges (for bullets, arrows, etc.). Will this be done on stage and by actors in the GameScreen class? Perhaps in the Rendering class? Or is it the second camera (loaded after the background)?

I am using the GameScreen class supported by the Map and MapRenderer classes to achieve my display.

I am going to separate the LibGdx tests. Any information to get my feet off the ground would be good!

+3
source share
1 answer

( ). , . libgdx (uiskin ).

public class HealthBar extends Actor {

    private NinePatchDrawable loadingBarBackground;

    private NinePatchDrawable loadingBar;

    public HealthBar() {
        TextureAtlas skinAtlas = new TextureAtlas(Gdx.files.internal("data/uiskin.atlas"));
        NinePatch loadingBarBackgroundPatch = new NinePatch(skinAtlas.findRegion("default-round"), 5, 5, 4, 4);
        NinePatch loadingBarPatch = new NinePatch(skinAtlas.findRegion("default-round-down"), 5, 5, 4, 4);
        loadingBar = new NinePatchDrawable(loadingBarPatch);
        loadingBarBackground = new NinePatchDrawable(loadingBarBackgroundPatch);
    }

    @Override
    public void draw(Batch batch, float parentAlpha) {
        float progress = 0.4f;

        loadingBarBackground.draw(batch, getX(), getY(), getWidth() * getScaleX(), getHeight() * getScaleY());
        loadingBar.draw(batch, getX(), getY(), progress * getWidth() * getScaleX(), getHeight() * getScaleY());
    }
}

, AssetManager Atlas, .

+5

All Articles