public void createSplashScene(OnCreateSceneCallback pOnCreateSceneCallback) { ResourcesManager.getInstance().loadSplashScreen(); splashScene = new SplashScene(); currentScene = splashScene; pOnCreateSceneCallback.onCreateSceneFinished(splashScene); }
public void createMenuScene() { ResourcesManager.getInstance().loadMenuResources(); menuScene = new MainMenuScene(); loadingScene = new LoadingScene(); SceneManager.getInstance().setScene(menuScene); disposeSplashScene(); }
@Override public void onRenderCreated() { try { ResourcesManager.getSharedInstance() .setExpansionPack("/mnt/sdcard/shadingzen/org.traxnet.shadingzen.tests.resources.zip"); loadGameInfo(); } catch (Exception ex) { Log.e("HelloWorld", "Unable to load game scene:" + ex.getMessage(), ex); } }
public void loadMenuScene(final Engine mEngine, SceneType sceneGameType) { setScene(loadingScene); if (gameScene != null && sceneGameType == gameScene.getSceneType()) { gameScene.disposeScene(); ResourcesManager.getInstance().unloadGameTextures(); } else if (simulationScene != null && sceneGameType == simulationScene.getSceneType()) { simulationScene.disposeScene(); ResourcesManager.getInstance().unloadSimulationTextures(); } mEngine.registerUpdateHandler( new TimerHandler( 0.1f, new ITimerCallback() { public void onTimePassed(final TimerHandler pTimerHandler) { mEngine.unregisterUpdateHandler(pTimerHandler); ResourcesManager.getInstance().loadMenuTextures(); setScene(menuScene); } })); }
public void loadGameScene(final Engine mEngine, final int stage) { setScene(loadingScene); ResourcesManager.getInstance().unloadMenuTextures(); mEngine.registerUpdateHandler( new TimerHandler( 0.1f, new ITimerCallback() { public void onTimePassed(final TimerHandler pTimerHandler) { mEngine.unregisterUpdateHandler(pTimerHandler); ResourcesManager.getInstance().loadGameResources(); gameScene = new GameScene(stage); setScene(gameScene); } })); }
/** * Default constructor, initializes all lists, creates new instance of ResourcesManager * * @see ResourcesManager */ public WorldManager() { _instance = this; civilAirports = new LinkedList<CivilAirport>(); intersections = new LinkedList<Intersection>(); militaryAirports = new LinkedList<MilitaryAirport>(); renderables = new LinkedList<IRenderable>(); buildings = new LinkedList<Building>(); airports = new LinkedList<Airport>(); harbors = new LinkedList<Harbor>(); vehicles = new LinkedList<Vehicle>(); paths = new LinkedList<Path>(); passengers = new LinkedBlockingQueue<Passenger>(); iVoyageTargets = new LinkedList<IVoyageTarget>(); ResourcesManager.getInstance(); }
public class SceneManager { private BaseScene splashScene; private BaseScene menuScene; private BaseScene simulationScene; private BaseScene gameScene; private BaseScene loadingScene; private BaseScene rampScene; private BaseScene levelSelector; private static final SceneManager INSTANCE = new SceneManager(); private SceneType currentSceneType = SceneType.SCENE_SPLASH; private BaseScene currentScene; private Engine engine = ResourcesManager.getInstance().engine; public enum SceneType { SCENE_SPLASH, SCENE_MENU, SCENE_SIMULATION, SCENE_GAME, SCENE_RAMP, SCENE_LOADING, SCENE_LEVEL_SELECTOR } // --------------------------------------------- // CLASS LOGIC // --------------------------------------------- public void setScene(BaseScene scene) { engine.setScene(scene); currentScene = scene; currentSceneType = scene.getSceneType(); } public void setScene(SceneType sceneType) { switch (sceneType) { case SCENE_MENU: setScene(menuScene); break; case SCENE_SIMULATION: setScene(simulationScene); break; case SCENE_GAME: setScene(gameScene); break; case SCENE_SPLASH: setScene(splashScene); break; case SCENE_LOADING: setScene(loadingScene); break; case SCENE_RAMP: setScene(rampScene); break; case SCENE_LEVEL_SELECTOR: setScene(levelSelector); break; default: break; } } // --------------------------------------------- // GETTERS AND SETTERS // --------------------------------------------- public static SceneManager getInstance() { return INSTANCE; } public SceneType getCurrentSceneType() { return currentSceneType; } public BaseScene getCurrentScene() { return currentScene; } public void createSplashScene(OnCreateSceneCallback pOnCreateSceneCallback) { ResourcesManager.getInstance().loadSplashScreen(); splashScene = new SplashScene(); currentScene = splashScene; pOnCreateSceneCallback.onCreateSceneFinished(splashScene); } private void disposeSplashScene() { ResourcesManager.getInstance().unloadSplashScreen(); splashScene.disposeScene(); splashScene = null; } public void createLevelSelectorScene() { levelSelector = new LevelSelectorScene(); SceneManager.getInstance().setScene(levelSelector); // disposeSplashScene(); } public void loadSimulationScene(final Engine mEngine) { setScene(loadingScene); ResourcesManager.getInstance().unloadMenuTextures(); mEngine.registerUpdateHandler( new TimerHandler( 0.1f, new ITimerCallback() { public void onTimePassed(final TimerHandler pTimerHandler) { mEngine.unregisterUpdateHandler(pTimerHandler); ResourcesManager.getInstance().loadSimulationResources(); simulationScene = new SimulationScene(); setScene(simulationScene); } })); } public void loadGameScene(final Engine mEngine, final int stage) { setScene(loadingScene); ResourcesManager.getInstance().unloadMenuTextures(); mEngine.registerUpdateHandler( new TimerHandler( 0.1f, new ITimerCallback() { public void onTimePassed(final TimerHandler pTimerHandler) { mEngine.unregisterUpdateHandler(pTimerHandler); ResourcesManager.getInstance().loadGameResources(); gameScene = new GameScene(stage); setScene(gameScene); } })); } public void loadRampScene(final Engine mEngine, final int stage) { setScene(loadingScene); ResourcesManager.getInstance().unloadMenuTextures(); mEngine.registerUpdateHandler( new TimerHandler( 0.1f, new ITimerCallback() { public void onTimePassed(final TimerHandler pTimerHandler) { mEngine.unregisterUpdateHandler(pTimerHandler); ResourcesManager.getInstance().loadGameResources(); rampScene = new RampScene(stage); setScene(rampScene); } })); } public void createMenuScene() { ResourcesManager.getInstance().loadMenuResources(); menuScene = new MainMenuScene(); loadingScene = new LoadingScene(); SceneManager.getInstance().setScene(menuScene); disposeSplashScene(); } public void loadMenuScene(final Engine mEngine, SceneType sceneGameType) { setScene(loadingScene); if (gameScene != null && sceneGameType == gameScene.getSceneType()) { gameScene.disposeScene(); ResourcesManager.getInstance().unloadGameTextures(); } else if (simulationScene != null && sceneGameType == simulationScene.getSceneType()) { simulationScene.disposeScene(); ResourcesManager.getInstance().unloadSimulationTextures(); } mEngine.registerUpdateHandler( new TimerHandler( 0.1f, new ITimerCallback() { public void onTimePassed(final TimerHandler pTimerHandler) { mEngine.unregisterUpdateHandler(pTimerHandler); ResourcesManager.getInstance().loadMenuTextures(); setScene(menuScene); } })); } }
private void disposeSplashScene() { ResourcesManager.getInstance().unloadSplashScreen(); splashScene.disposeScene(); splashScene = null; }
/** SceneManager will take care to display the correct Scene */ public class SceneManager { private BaseScene gameScene; private BaseScene replayScene; private BaseScene loadingScene; private static final SceneManager INSTANCE = new SceneManager(); private BaseScene currentScene; private Engine engine = ResourcesManager.getInstance().engine; public static SceneManager getInstance() { return INSTANCE; } public BaseScene getCurrentScene() { return currentScene; } public void setScene(BaseScene scene) { if (currentScene != null) { // Unload the current scene from the memory currentScene.disposeScene(); } engine.setScene(scene); currentScene = scene; } public void createLoadingScene(IGameInterface.OnCreateSceneCallback pOnCreateSceneCallback) { loadingScene = new LoadingScene(); SceneManager.getInstance().setScene(loadingScene); pOnCreateSceneCallback.onCreateSceneFinished(loadingScene); } public void loadGameScene(final Engine engine) { loadingScene = new LoadingScene(); setScene(loadingScene); engine.registerUpdateHandler( new TimerHandler( 0.1f, new ITimerCallback() { @Override public void onTimePassed(TimerHandler pTimerHandler) { engine.unregisterUpdateHandler(pTimerHandler); ResourcesManager.getInstance().loadGameResources(); gameScene = new GameScene(); setScene(gameScene); } })); } public void loadReplayScene(final Engine engine) { loadingScene = new LoadingScene(); setScene(loadingScene); engine.registerUpdateHandler( new TimerHandler( 0.1f, new ITimerCallback() { @Override public void onTimePassed(TimerHandler pTimerHandler) { engine.unregisterUpdateHandler(pTimerHandler); ResourcesManager.getInstance().loadGameResources(); replayScene = new ReplayScene(); setScene(replayScene); } })); } }