示例#1
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            //First update the input handler
            //inputHandler.Update(gameTime);

            // Work with a copy of the screens list, so the main list doesn't have
            // to be altered.
            screensToUpdate.Clear();
            foreach (GameScreen screen in screens)
            {
                screensToUpdate.Add(screen);
            }

            while (screensToUpdate.Count > 0)
            {
                //Remove screen from the update list, then call its Update method.
                GameScreen screen = screensToUpdate[screensToUpdate.Count - 1];
                screensToUpdate.RemoveAt(screensToUpdate.Count - 1);

                screen.Update(gameTime);
                screen.HandleInput(inputHandler);
            }

            base.Update(gameTime);
        }