Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Best way to add Buttons in libgdx.  (Read 6069 times)
0 Members and 1 Guest are viewing this topic.
Offline RUSD

Junior Duke


Projects: 2



« Posted 2013-05-24 23:18:34 »

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.
Offline Cero
« Reply #1 - Posted 2013-05-24 23:20:15 »

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?

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

Offline Andre Lopes
« Reply #2 - Posted 2013-05-25 01:02:24 »

SO in order to draw buttons, you need to use Stage ?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #3 - Posted 2013-05-25 04:31:08 »

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.

Offline Phibedy

Senior Duke


Medals: 9



« Reply #4 - Posted 2013-05-25 14:32:48 »

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.
Offline dermetfan
« Reply #5 - Posted 2013-05-25 15:16:08 »

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

Offline Andre Lopes
« Reply #6 - Posted 2013-05-25 16:13:38 »

yay ty for those videos, why havent u post them EARLIER ? Cheesy Cheesy Cheesy im subscribing and watching them all!!!
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 136
Projects: 4
Exp: 3 years



« Reply #7 - Posted 2013-05-25 16:14:41 »

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

Junior Duke


Projects: 2



« Reply #8 - Posted 2013-05-25 23:54:01 »

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.
Offline dermetfan
« Reply #9 - Posted 2013-05-29 00:42:01 »

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 Lips Sealed

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline RUSD

Junior Duke


Projects: 2



« Reply #10 - Posted 2013-06-03 23:00:38 »

thanks  I'll watch the videos.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (33 views)
2014-10-27 03:28:38

TehJavaDev (27 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (59 views)
2014-10-16 15:22:06

Norakomi (48 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!