PhoneMainMenuScreen.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // PhoneMainMenuScreen.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. using Microsoft.Xna.Framework;
  10. using System;
  11. namespace GameStateManagementSample
  12. {
  13. class PhoneMainMenuScreen : PhoneMenuScreen
  14. {
  15. public PhoneMainMenuScreen()
  16. : base("Main Menu")
  17. {
  18. // Create a button to start the game
  19. Button playButton = new Button("Play");
  20. playButton.Tapped += playButton_Tapped;
  21. MenuButtons.Add(playButton);
  22. // Create two buttons to toggle sound effects and music. This sample just shows one way
  23. // of making and using these buttons; it doesn't actually have sound effects or music
  24. BooleanButton sfxButton = new BooleanButton("Sound Effects", true);
  25. sfxButton.Tapped += sfxButton_Tapped;
  26. MenuButtons.Add(sfxButton);
  27. BooleanButton musicButton = new BooleanButton("Music", true);
  28. musicButton.Tapped += musicButton_Tapped;
  29. MenuButtons.Add(musicButton);
  30. }
  31. void playButton_Tapped(object sender, EventArgs e)
  32. {
  33. // When the "Play" button is tapped, we load the GameplayScreen
  34. LoadingScreen.Load(ScreenManager, true, PlayerIndex.One, new GameplayScreen());
  35. }
  36. void sfxButton_Tapped(object sender, EventArgs e)
  37. {
  38. BooleanButton button = sender as BooleanButton;
  39. // In a real game, you'd want to store away the value of
  40. // the button to turn off sounds here. :)
  41. }
  42. void musicButton_Tapped(object sender, EventArgs e)
  43. {
  44. BooleanButton button = sender as BooleanButton;
  45. // In a real game, you'd want to store away the value of
  46. // the button to turn off music here. :)
  47. }
  48. #if !__IOS__
  49. protected override void OnCancel()
  50. {
  51. //ScreenManager.Game.Exit();
  52. base.OnCancel();
  53. }
  54. #endif
  55. }
  56. }