I am currently working on a dialog window for my android game using libgdx. This dialog window contains a collection of labels and buttons, but should also contain an image. The image represents the "remaining health indicator", i.e. an empty indicator with a symbol indicating the health of the player. This indicator has to be filled with a colored rectangle representing the remaining amount of health (see screenshot below).
In order to render this on a dialog of libgdx, I have to draw an image and a colored rectangle (the red rectangle indicating the real amount of remaining health). I know that the dialog supports the rendering of images, but I don't know how to first draw the rectangle.
This is the code I have so far:
public FuelFacilityDialog(GameWorld world, GuiComponent gui) { super("Health check", gui.defaultSkin);
this.world = world;
this.gui = gui;
setModal(true);
setMovable(false);
setResizable(false);
Image healthIndicator = new Image();
Button button1 = new TextButton("heal", gui.defaultSkin);
Button button4 = new TextButton("Exit", gui.defaultSkin);
healthIndicator.setDrawable(new TextureRegionDrawable(AssetLoader.healthIndicatorV));
healthIndicator.setScaling(Scaling.fit);
setObject(button1, true);
setObject(button4, false);
Table imageTable = new Table();
Table buttonTable = new Table();
imageTable.add(healthIndicator).width(100).height(200);
buttonTable.add(button1).width(100).height(50).expandY();
this.getContentTable().padTop(20);
this.getContentTable().padBottom(20);
this.getContentTable().add(imageTable);
this.getContentTable().add(buttonTable).height(200);
getButtonTable().add(button2);
}