Is it just me or is messing with Scene2D tedious as hell.
I have been coding a Space Invaders game for the past couple of days, using LibGDX and I have the game almost complete (death animation missing) so I decided to add a menu.
Now it would have 2 buttons, play and quit. Jesus, the amount of fields/variables required to just do that was horrible.
Then the skin, god annoying.
Don’t get me wrong, I have used it to good effect in the past but it just feels like a tedious and ugly library when it comes to coding with it.
Anyone feel the same or just me?
I ended up just creating a simple UIHandler, a few buttons, a list to holds the buttons and a way to navigate them with the keys.
It took around 5-6 classes but all I have to do is this:
UIHandler uiHandler = new UIHandler();
TextButton play = new TextButton("PLAY", Gdx.graphics.getWidth() / 2,
Gdx.graphics.getHeight() / 2, 300, 100, new ButtonCallback() {
@Override
public void onClick() {
((Game)Gdx.app.getApplicationListener()).setScreen(new GameScreen());
}
});
TextButton exit = new TextButton("QUIT", Gdx.graphics.getWidth() / 2,
Gdx.graphics.getHeight() / 2, 300, 100, new ButtonCallback() {
@Override
public void onClick() {
Gdx.app.exit();
}
});
list.addWidget(play);
list.addWidget(exit);
uiHandler.addWidget(list);
You can see where the similarities lie, the ui hander is like the Stage and the list is like the List in Scene2D, this was pretty fun to write, it might not look pretty but at least I am not fighting with a whole bunch of exceptions to get Scene2D to agree