Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building a 3D Game with LibGDX

You're reading from  Building a 3D Game with LibGDX

Product type Book
Published in Aug 2016
Publisher Packt
ISBN-13 9781785288418
Pages 234 pages
Edition 1st Edition
Languages

Scene2D


Every game has information that the player needs to know, and LibGDX tackles this with an API called Scene2D to help us develop and manage the UI with easy, clean, and powerful implementations.

The preceding image is an example of the UI for our game. It's displaying the Score (top left), a Health bar, an Oxigen bar, and an Energy bar (bottom middle), and a pause button (top right).

Scene2D is LibGDX's scene graph; its basically, a scene where actors play. It consists of scenes that contain nods and can contain them on various layers. The benefit of using this approach is based on performance, productivity, portability, and scalability.

Using Scene2D is as simple as instantiating a Stage class and adding actors to it.

We'll start with creating a class that will handle all UI draws and changes; we'll add what we need on GameScreen.java first:

public class GameScreen implements Screen { 
   ... 
   GameUI gameUI; 
   public GameScreen(Core game) { 
       ... 
...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}