Here is some code I used to mimic a health bar. I used a ProgressBar
.
stage = new Stage();
Texture bground = new Texture(Gdx.files.internal("pbBackground.png"));
Table table = new Table();
table.setFillParent(true);
stage.addActor(table);
font = new BitmapFont(Gdx.files.internal("gamefonts.fnt"));
font.getData().scale(.1f);
skin = new Skin();
pixmap = new Pixmap(1, 1, Format.RGBA8888);
pixmap.setColor(Color.WHITE);
pixmap.fill();
skin.add("white", new Texture(pixmap));
LabelStyle lstyle = new LabelStyle();
lstyle.font=font;
Label mylabel = new Label("HP", lstyle);
mylabel.setColor(Color.RED);
mylabel.setPosition(1, 6);
table.addActor(mylabel);
textureBar = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("pb.png"))));
barStyle = new ProgressBarStyle(skin.newDrawable("white", Color.DARK_GRAY), textureBar);
barStyle.background = new TextureRegionDrawable(new TextureRegion(bground));
barStyle.knobBefore=barStyle.knob;
bar = new ProgressBar(0, 10, 0.5f, false, barStyle);
bar.setPosition(1, 1);
bar.setValue(0);
bar.setAnimateDuration(2);
table.addActor(bar);
This website may help you understand progressbars better. Also look at the docs for ProgressBar.
Image
actor to theStage
if you want, or you can get theStage
sSpriteBatch
and draw with it.