/// <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>
        public override void Update(GameTime gameTime)
        {
            TouchCollection touches;

            // Update all game objects
            _game.UpdateAll(gameTime);

            // Has the player touched the screen or pressed the back button?
            touches = TouchPanel.GetState();
            if (touches.Count == 1 && touches[0].State == TouchLocationState.Pressed
                ||
                GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                // Return back to the menu
                Game.SetGameMode <Mode_Menu>();
            }

            base.Update(gameTime);
        }
示例#2
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>
        public override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                _game.Exit();
            }

            TouchCollection touches;
            SpriteObject    touchedText;

            // Update all game objects
            _game.UpdateAll(gameTime);

            // Has the player touched the screen?
            touches = TouchPanel.GetState();
            if (touches.Count == 1 && touches[0].State == TouchLocationState.Pressed)
            {
                // Find which text object (if any) has been touched
                touchedText = Game.GetSpriteAtPoint(touches[0].Position);
                // Did we get something?
                if (touchedText != null)
                {
                    // See what it was
                    switch (touchedText.Tag)
                    {
                    case "NewGame":
                        // Switch to gameplay mode
                        Game.SetGameMode <Mode_Game>();
                        // Reset for a new game
                        Game.CurrentGameModeHandler.Reset();
                        break;

                    case "ResumeGame":
                        // Is the game already active?
                        if (Game.GetGameModeHandler <Mode_Game>().GameIsActive)
                        {
                            // Yes, so switch back to the existing game
                            Game.SetGameMode <Mode_Game>();
                        }
                        break;

                    case "HighScores":
                        // Switch to High Scores mode
                        Game.SetGameMode <Mode_HighScores>();
                        break;

                    case "Settings":
                        // Switch to Settings mode
                        Game.SetGameMode <Mode_Settings>();
                        break;

                    case "Credits":
                        // Switch to Credits mode
                        Game.SetGameMode <Mode_Credits>();
                        break;
                    }
                }
            }

            base.Update(gameTime);
        }