Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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  
  [LibGDX] How to Make Game HUD and UI?  (Read 5459 times)
0 Members and 1 Guest are viewing this topic.
Offline Rayexar

Junior Member


Medals: 2



« Posted 2013-08-10 08:47:59 »

Hey,

Basically, I just want a simple on-screen HUD with some text and a few buttons. One of the buttons is meant to bring up a "player inventory" which should just be a grid with items in it.

More specifically, I'm not sure how to render the HUD/UI on the game Screen amd how to handle the input. Can anyone please give some suggestions on how this can be handled?

Thank you very much!
Offline StumpyStrust
« Reply #1 - Posted 2013-08-10 09:02:02 »

Look into scene2d in libgdx. A bit of work getting the skins stuff going but once done rather easy. You can use the scene2d stuff just for rendering the UI and do your own stuff for the rest of the game.

Offline Otreum

Junior Member


Medals: 6



« Reply #2 - Posted 2013-08-10 09:03:27 »

I am just gonna drop this one in here. It is a good series of LibGDX tutorials which include UI stuff.
http://www.youtube.com/playlist?list=PLXY8okVWvwZ0qmqSBhOtqYRjzWtUCWylb

Also this.
http://www.youtube.com/playlist?list=PLXY8okVWvwZ0JOwHiH1TntAdq-UDPnC2L

There are a few other tutorials out there which cover more in depth on how to create your own UI, menu, splash screens, inventory etc etc.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Rayexar

Junior Member


Medals: 2



« Reply #3 - Posted 2013-08-10 10:03:13 »

scene2d seems fairly complicated to use, especially for just some basic UIs. Do you think it's easier use scene2d or create the HUD/UI graphics and manually draw and handle input?

Offline StumpyStrust
« Reply #4 - Posted 2013-08-10 12:09:21 »

Everything is at first. Setting up the stuff can be a pain, but once that is done, rather smooth. I would not recommend doing it yourself unless you want to learn how. If you want to make games, use apis.

Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #5 - Posted 2013-08-10 12:26:52 »

Which part of scene2d is complicated at first? See this:
https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/UISimpleTest.java#L43

Offline Rayexar

Junior Member


Medals: 2



« Reply #6 - Posted 2013-08-10 13:29:43 »

It doesn't seem too difficult now after looking at some examples. It seemed complicated at first because I was overwhelmed at how much information there was on scene2d. Thanks everyone for the links and advice.
Offline davedes
« Reply #7 - Posted 2013-08-10 15:48:53 »

The only complicated part of Scene2D is finding the default skins... Tongue Which IMHO should be included in LibGDX, like BitmapFont's default font.

Offline StumpyStrust
« Reply #8 - Posted 2013-08-11 01:35:42 »

Yes davedes oh God yes.

Offline Rayexar

Junior Member


Medals: 2



« Reply #9 - Posted 2013-08-11 09:30:27 »

I've been learning scene2d but I don't fully get skins and tablelayout. How would I, for example, create a simple ImageButton and draw it on the screen?

I have a stage, table and skin. I added a texture to the skin like so
1  
skin.add("bluebutton", new Texture(Gdx.files.internal("ui/bluebutton.png")), Texture.class);
, but how do I set the position of the ImageButton and draw it on the screen? ImageButton has constructors which take a skin, ImageButtonStyle and drawable, but I'm not sure which one to use?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #10 - Posted 2013-08-11 19:52:35 »

davedes, maybe is we get Shiu to create a skin that isn't ass. Wink

Rayexar, any of the constructors are fine. If you have a skin then use a skin constructor. Probably you want to use Button though, not ImageButton.

Offline Rayexar

Junior Member


Medals: 2



« Reply #11 - Posted 2013-08-12 11:24:43 »

Ok, thanks for that. Now I'm having trouble setting the position of Buttons. button.setPosition(x, y) has no effect, and button.pad(x) also has no effect.

Edit: table.align(int align) allows me to set the alignment, and I found out about table.row(), but that still allow me to more specifically set the position of buttons.

Can someone please explain what button.pad(float x) does? It seems to have no effect, but when i set x to 100, the  button suddenly gets stretched out.
Offline Rayexar

Junior Member


Medals: 2



« Reply #12 - Posted 2013-08-12 11:44:04 »

Alright, I figured it out. Using a combination of methods like these seems to work:
1  
2  
3  
4  
table.add(button).padRight(10).padLeft(10);
      table.add(button2);

      table.left().bottom();
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #13 - Posted 2013-08-13 00:30:02 »

http://code.google.com/p/table-layout/

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.

CogWheelz (15 views)
2014-08-01 22:53:16

CogWheelz (15 views)
2014-08-01 22:51:43

CopyableCougar4 (16 views)
2014-08-01 19:37:19

CogWheelz (19 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

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

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

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22
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!