Example #1
0
        // Push a gamescreen on top of the stack
        public void PushGameScreen(GameScreen gameScreen)
        {
            //Throw exception if the GameScreen is already in use
            if (gameScreen.Engine != null)
            {
                throw new Exception ("This GameScreen already exists on the stack of another " +
                    "Engine instance");
            }

            if (!gameScreens.Contains(gameScreen))
            {
                gameScreens.Add(gameScreen);
                gameScreen.engine = this;
                gameScreen.LoadGameScreen();

                if (OnScreenChange != null)
                    OnScreenChange(this, new ScreenEventArgs(gameScreen));

            }
        }
Example #2
0
 // less code with this :)
 public void ChangeGameScreen(GameScreen screen)
 {
     PopGameScreen();
     PushGameScreen(screen);
 }