LibGDX 2D RTS game GUI

Hello everyone,

I want to build a RTS game using LibGDX, and I’m really clueless on how to make a working GUI.
I followed this 2-years-old tutorial to create a little test screen where I have a unit that moves and zoom in/zoom out. I understand that it has to be done using Stage, so I created a Unit class (with parameters like hp, attack, max speed, etc.) which extends Actor.
What I want to achieve is an overlay of panels and buttons over the game’s scrollable and zoomable “world” that would remain static wherever I move my camera or whether I zoom in or out.
Can anyone please explain (or show) how to ceate that kind of interface using LibGDX?

Thanks in advance ;D

Hey PolarBearOC,

I believe what you really want to do is to have two different cameras, one for the UI where the measurement unit is in pixels, and one for the world, where things are usually measured in meters.

Think of it like a full 3D game, the GUI remains static no matter what, you can walk around, zoom in, zoom out, and your interface will still be there, while the world is fully dynamic and can be translated, rotated, zoomed, etc. The only difference is that with 2D you only work with two axes instead of three, but the concept of the camera is the same.

For both cases what you will need is an OrthographicCamera (assuming you want to go 2D, otherwise use a PerspectiveCamera for your world). A pseudo code would look like this:
http://pastebin.java-gaming.org/5992771274015

Alternatively you could use Scene2D (where Stage and Actors come from), but that’s a whole new thing and very different than LibGDX itself.

I hope that helps at least a bit :slight_smile: