Back to project page X3n0break.
The source code is released under:
GNU General Public License
If you think the Android project X3n0break listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.x3n0m0rph59.breakout; /* w w w . j a va 2 s . c om*/ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; import com.badlogic.gdx.utils.IntMap; public final class ScreenManager { private static final ScreenManager instance = new ScreenManager(); private final IntMap<Screen> screens; private ScreenManager() { screens = new IntMap<Screen>(); } public void showScreen(ScreenType screen) { if (!screens.containsKey(screen.ordinal())) { screens.put(screen.ordinal(), screen.getScreenInstance()); } ((App) Gdx.app.getApplicationListener()).setScreen(screens.get(screen.ordinal())); } public Screen getScreen(ScreenType screen) { if (!screens.containsKey(screen.ordinal())) { screens.put(screen.ordinal(), screen.getScreenInstance()); } return screens.get(screen.ordinal()); } public void overrideAndShowScreen(ScreenType type, Screen screen) { screens.put(type.ordinal(), screen); showScreen(type); } public void dispose(ScreenType screen) { Logger.debug("Disposing screen: " + screen); if (!screens.containsKey(screen.ordinal())) return; screens.remove(screen.ordinal()).dispose(); } public void dispose() { Logger.debug("Disposing all screens"); for (Screen screen : screens.values()) { screen.dispose(); } screens.clear(); } public static ScreenManager getInstance() { return instance; } }