This library is a screen manager for libGDX games. It allows comfortably changing the rendered screen while using transition effects. The library's easy to use nature makes it possible to integrate libgdx-screenmanager into any project without much effort.
- Allows easily changing the rendered screen (
game.getScreenManager().pushScreen("screen_name", "transition_name")
) - Adds screen transition effects for when a screen is changed. The included transitions can be found here. Furthermore, transition shaders are supported as well (see the GL Transitions project for a collection of some very well made ones).
- Automatically registers/unregisters the screen's input processors whenever the screen is shown/hidden
- There are
create()
methods for screens and transitions that are called once before a screen/transition is shown. This allows easily initializing them when everything else has already been loaded - The whole library is well documented and includes tests for everything that isn't graphical
A small example using different transitions. Look at the showcases folder for more gifs.
The following example shows how to use libgdx-screenmanager in your code. You can find the full example here.
The library is very easy to use: The game has to extend ManagedGame
, all screen have to inherit from ManagedScreen
. Screens and transitions have to be registered with the screen manager before they can be used. To push a screen game.getScreenManager().pushScreen("screen-name", "transition-name")
has to be called. If no transition should be used, just call pushScreen("screen-name", null)
.
public class MyGdxGame extends ManagedGame<MyScreenClass, ScreenTransition> {
@Override
public final void create() {
super.create();
// Do some basic stuff
this.batch = new SpriteBatch();
// Add screens
this.screenManager.addScreen("green", new GreenScreen());
this.screenManager.addScreen("blue", new BlueScreen());
// ...
// Add transitions
BlendingScreenTransition blendingTransition = new BlendingScreenTransition(batch, 1F);
screenManager.addScreenTransition("blending_transition", blendingTransition);
// ...
// Push the first screen using a blending transition
this.screenManager.pushScreen("green", "blending_transition");
Gdx.app.debug("Game", "Initialization finished.");
}
}
Some additional notes:
- Input processors have to be added in a screen via
ManagedScreen#addInputProcessor(...)
. This is needed so the input processors can be automatically registered/unregistered when the screen is shown/hidden.
In the wiki you can find articles detailing the usage of the library and its inner workings.