I’m pretty new, but based on what I saw in the Simple Game Tutorial from LibGDX and the Breakout game I’m working on, it’s fairly simple.
Essentially, your main class for the project will manage everything you need and you can pass an instance of it to your screens so that they can use everything from that one class and still remain lightweight and functional.
I’ve omitted all of the code that doesn’t pertain so you can see what I’ve done.
In my case, the main class is BreakOutGame:
public class BreakOutGame extends Game {
@Override
public void create() {
this.setScreen(new MainMenuScreen(this)); // This is the code that actually sets the first screen of your game.
}
@Override
public void render() {
super.render(); // Don't forget to use super.render();
}
}
Notice in the onCreate(); method is the code for switching the screens. That’s where you would create a class to serve as one of your screens, such as MainMenuScreen in my case.
Create a class and implement Screen, then generate the methods it needs.
Use a constructor to serve as your onCreate() method with a parameter of the instance of the game. In my case:
public class MainMenuScreen implements Screen {
public MainMenuScreen(BreakOutGame bog)
{
this.bog = bog;
}
Hope it helps!