Best way to add Buttons in libgdx.

I’m trying to learn libgdx, (so far I like it).

What would be the best way to add buttons to a game.

I kind of know how to add buttons to a Screen, but when i try to do that I can no longer play my game. the buttons take over and i cant click anything else. Am I doing it wrong?

Is the best way to just draw a sprite then detect when i click on that sprite? or is there a better way to add buttons?

I’d like some Ideas or a link to a tutorial. Thanks.

Possible and might be enough depending on what you need. Otherwise look at Scene2D Ui. Its quite nice.

SO in order to draw buttons, you need to use Stage ?

When you add button to stage, the stage will handle the render and act simply by doing addActor(). It’s recommended to use stage for messing with scene2d and table.

scene2d is the right choice: http://code.google.com/p/libgdx/wiki/scene2d
there is also twl: http://l33tlabs.org/, but you should prefer scene2d, it’s much easier.

Of course you could also write your own ui-system, but I wouldn’t recommend that.

[quote]I’d like some Ideas or a link to a tutorial.
[/quote]
I think this allows me to do some self-advertisement here. In Episode 6 of my LibGDX Tutorials, we add a TextButton.

yay ty for those videos, why havent u post them EARLIER ? :smiley: :smiley: :smiley: im subscribing and watching them all!!!

Good post here: http://steigert.blogspot.com/2012/03/4-libgdx-tutorial-tablelayout.html

Those are all good for creating menus. I’m making a tower defense game and on the side i’d like to add buttons for selecting tower types, pausing the game, or quitting and returning to the main menu. How would you recommend I do that? I don’t really want to bring up a menu or another screen for that.

You can just put a Stage over your game (if you’re not already using one) and put buttons on the stage. Empty space on the stage is transparent, so you can still see what’s going on in your game.
If you’re already using a Stage for your game, you could add a Window to it. Also, I’m self-advertising here again…
tutorial: pause Window and multiple Stages. Sorry :-X

thanks I’ll watch the videos.