Update() public static méthode

public static Update ( GameTime t ) : void
t Microsoft.Xna.Framework.GameTime
Résultat void
Exemple #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape) || !running)
            {
                Exit();
            }

            currState.Update(gameTime);
            AudioManager.Update(gameTime);

            // Handle GameState transitions
            GameState newState = currState.GetTransition();

            if (newState != null)
            {
                //Set map
                if (newState == game)
                {
                    ((StateGame)game).setMaps(((StateLevelSelect)levelMenu).getSelectedMap());
                }
                if (newState == winScreen)
                {
                    ((StateWin)winScreen).setMap(((StateLevelSelect)levelMenu).getSelectedMap().getName() + "/victory");
                    ((StateWin)winScreen).setPlayers(((StateGame)game).players);
                }

                //State unload/load
                currState.UnloadContent();
                currState = newState;
                currState.Initialize();
                currState.LoadContent(Content);
            }


            base.Update(gameTime);
        }