Пример #1
0
        public override void Update(GameTime gameTime)
        {
            // Clear out the screensToUpdate list to copy the screens list
            // This allows us to add or remove screens without complaining
            screensToUpdate.Clear();

            // If there are ever 0 screens on the stack, then close the game
            if (screens.Count == 0)
            {
                this.Game.Exit();
            }
            foreach (GameScreen screen in screens)
            {
                screensToUpdate.Add(screen);
            }

            bool screenIsCovered = false;
            bool firstScreen     = true;

            if (!Game.IsActive)
            {
                // If the game isn't the active window, then pause everything.
            }
            else
            {
                while (screensToUpdate.Count > 0)
                {
                    GameScreen screen = screensToUpdate[screensToUpdate.Count - 1];
                    screensToUpdate.RemoveAt(screensToUpdate.Count - 1);

                    // Update the screen
                    screen.Update(gameTime, screenIsCovered);

                    if (screen.IsActive)
                    {
                        if (firstScreen)
                        {
                            screen.HandleInput();
                            firstScreen = false;
                        }
                        if (!screen.IsPopup)
                        {
                            screenIsCovered = true;
                        }
                    }
                }
            }
        }