Answer the question
In order to leave comments, you need to log in
How to properly create a button on libGDX?
So I created a button, but somehow there is a lot for one button, maybe you can do it somehow differently?
public class PlayButton extends Button {
public static final float WIDTH = 160;
public static final float HEIGHT = 60;
MainMenuScreen screen;
public static final Drawable drawableDown = new Image(Assets.playHoverButton).getDrawable();
public static final Drawable drawableUp = new Image(Assets.playButton).getDrawable();
public PlayButton(final MainMenuScreen screen) {
super(drawableUp, drawableDown);
this.screen = screen;
setSize(WIDTH, HEIGHT);
addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
screen.getGame().setScreen(new ChooseLocationScreen(screen.getGame()));
}
});
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question