Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (582)
Games in Android Showcase (163)
games submitted by our members
Games in WIP (633)
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 11948 times)
0 Members and 1 Guest are viewing this topic.
Offline Rayexar
« Posted 2013-08-10 06:47:59 »


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 07: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 Devvie

Medals: 6

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

I am just gonna drop this one in here. It is a good series of LibGDX tutorials which include UI stuff.

Also this.

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
« Reply #3 - Posted 2013-08-10 08: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 10: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 Bitwise Duke »

Medals: 164
Projects: 4
Exp: 14 years

Esoteric Software

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

Which part of scene2d is complicated at first? See this:

Offline Rayexar
« Reply #6 - Posted 2013-08-10 11: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 13: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-10 23:35:42 »

Yes davedes oh God yes.

Offline Rayexar
« Reply #9 - Posted 2013-08-11 07: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
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 Bitwise Duke »

Medals: 164
Projects: 4
Exp: 14 years

Esoteric Software

« Reply #10 - Posted 2013-08-11 17: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
« Reply #11 - Posted 2013-08-12 09: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
« Reply #12 - Posted 2013-08-12 09:44:04 »

Alright, I figured it out. Using a combination of methods like these seems to work:

Offline Nate

« JGO Bitwise Duke »

Medals: 164
Projects: 4
Exp: 14 years

Esoteric Software

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

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Ralphanese (16 views)
2015-05-29 13:07:55

Gibbo3771 (12 views)
2015-05-29 06:54:17

Ralphanese (23 views)
2015-05-28 16:52:52

theagentd (31 views)
2015-05-27 22:21:17

theagentd (35 views)
2015-05-27 22:21:08

CopyableCougar4 (25 views)
2015-05-27 19:24:50

MrMapcom (24 views)
2015-05-23 20:26:16

MrMapcom (32 views)
2015-05-23 20:23:34

Waterwolf (37 views)
2015-05-20 15:01:45

chrislo27 (44 views)
2015-05-20 03:42:21
Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

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 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‑
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!