PhonePauseScreen.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // PhonePauseScreen.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. using System;
  10. namespace GameStateManagementSample
  11. {
  12. /// <summary>
  13. /// A basic pause screen for Windows Phone
  14. /// </summary>
  15. class PhonePauseScreen : PhoneMenuScreen
  16. {
  17. public PhonePauseScreen()
  18. : base("Paused")
  19. {
  20. // Create the "Resume" and "Exit" buttons for the screen
  21. Button resumeButton = new Button("Resume");
  22. resumeButton.Tapped += resumeButton_Tapped;
  23. MenuButtons.Add(resumeButton);
  24. Button exitButton = new Button("Exit");
  25. exitButton.Tapped += exitButton_Tapped;
  26. MenuButtons.Add(exitButton);
  27. }
  28. /// <summary>
  29. /// The "Resume" button handler just calls the OnCancel method so that
  30. /// pressing the "Resume" button is the same as pressing the hardware back button.
  31. /// </summary>
  32. void resumeButton_Tapped(object sender, EventArgs e)
  33. {
  34. OnCancel();
  35. }
  36. /// <summary>
  37. /// The "Exit" button handler uses the LoadingScreen to take the user out to the main menu.
  38. /// </summary>
  39. void exitButton_Tapped(object sender, EventArgs e)
  40. {
  41. LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(),
  42. new PhoneMainMenuScreen());
  43. }
  44. protected override void OnCancel()
  45. {
  46. ExitScreen();
  47. base.OnCancel();
  48. }
  49. }
  50. }