/// <summary> /// Accepts a load request from a screen. Transitions from the screen to the loading screen while loading. /// Transitions back to the original screen after loading is complete /// </summary> /// <param name="screenToLoad">The screen requesting the load operation</param> /// <param name="loadMethod">The method containing the loading logic for the screen</param> /// <param name="loadArgs">All arguments required for the loadMethod</param> public void LoadScreenContent(GameScreen screenToLoad, Delegate loadMethod, params object[] loadArgs) { // Transitions from the loading screen to the original screen Action FinalizeLoad = () => { loadingScreen.Hide(); activeScreen = screenToLoad; screenToLoad.Show(); }; screenToLoad.Hide(); activeScreen = loadingScreen; loadingScreen.LoadScreenContent(loadMethod, FinalizeLoad, loadArgs); loadingScreen.Show(); }
public override void Initialize() { startScreen = new StartScreen(game, spriteBatch, game.Content.Load<SpriteFont>("menufont"), game.Content.Load<Texture2D>("alienmetal")); startScreen.Initialize(); startScreen.Hide(); actionScreen = new ActionScreen(game, spriteBatch); actionScreen.Initialize(); actionScreen.Hide(); editScreen = new EditScreen(game, spriteBatch); editScreen.Initialize(); editScreen.Hide(); loadingScreen = new LoadingScreen(game, spriteBatch); loadingScreen.Initialize(); loadingScreen.Hide(); activeScreen = startScreen; activeScreen.Show(); base.Initialize(); }
private void handleInput() { keyboardState = Keyboard.GetState(); // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) game.Exit(); if (activeScreen == startScreen) { if (CheckKey(Keys.Enter)) { if (startScreen.SelectedIndex == 0) { activeScreen.Hide(); activeScreen = actionScreen; actionScreen.RequestLoadLevel("Tilemaps/Level-1.0"); } if (startScreen.SelectedIndex == 1) { activeScreen.Hide(); activeScreen = editScreen; activeScreen.Show(); } if (startScreen.SelectedIndex == 2) { game.Exit(); } } if (CheckKey(Keys.Escape)) { game.Exit(); } } oldKeyboardState = keyboardState; }