/// <summary> /// Allows each screen to run logic. /// </summary> public override void Update(GameTime gameTime) { // Read the keyboard and gamepad. input.Update(); // Make a copy of the master screen list, to avoid confusion if // the process of updating one screen adds or removes others. screensToUpdate.Clear(); foreach (GameScreen screen in screens) { screensToUpdate.Add(screen); } bool otherScreenHasFocus = !Game.IsActive; bool coveredByOtherScreen = false; // Loop as long as there are screens waiting to be updated. while (screensToUpdate.Count > 0) { // Pop the topmost screen off the waiting list. GameScreen screen = screensToUpdate[screensToUpdate.Count - 1]; screensToUpdate.RemoveAt(screensToUpdate.Count - 1); // Update the screen. screen.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); if (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.Active) { // If this is the first active screen we came across, // give it a chance to handle input. if (!otherScreenHasFocus) { screen.HandleInput(input, gameTime); otherScreenHasFocus = true; } // If this is an active non-popup, inform any subsequent // screens that they are covered by it. if (!screen.IsPopup) { coveredByOtherScreen = true; } } } // cast from framework Game class to ours GameStateManagementGame myGame = (GameStateManagementGame)Game; // Toggle fixed time step if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.F)) { myGame.IsFixedTimeStep = !myGame.IsFixedTimeStep; myGame.m_kFrameRate.ResetFPSCount(); } // Increase or decrease our target ms per frame, which inversely effects the framerate if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.OemMinus)) { myGame.fTargetMsPerFrame += 3.0f; myGame.m_kFrameRate.ResetFPSCount(); } else if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.OemPlus)) { myGame.fTargetMsPerFrame -= 3.0f; myGame.m_kFrameRate.ResetFPSCount(); } // Print debug trace? if (traceEnabled) { TraceScreens(); } }