I'm having problems with creating static HUD/buttons on the game screen. Currently my game has a character moving on the tiled map, with OrthographicCamera put on, everything works fine. I wanted to add button on the screen:
...
Stage stage;
ImageButton imageButton;
@Override
public void create() {
stage = new Stage(viewport);
Texture texture = new Texture("bagbutton.png");
Drawable drawable = new TextureRegionDrawable(new TextureRegion(texture));
imageButton = new ImageButton(drawable);
imageButton.setPosition(200, 200);
imageButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent inputEvent, float x, float y) {
System.out.println("clicked");
}
});
Gdx.input.setInputProcessor(stage);
stage.addActor(imageButton);
}
...
And then in render() method I got
stage.draw();
button appears, indeed, and it's even clickable. However, my player image (drawn by spritebatch.draw with texture) disappeared. Moreover, button is in the same position on map, and I'd like it to be somewhere on the bottom of the screen. It should be there statically, too, always in the same place, so when players moves, the button is always in the same place on screen. Next I'd like to make the same thing with some text and image, let's say on the top of screen. How to make it so?