コード例 #1
0
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public MainMenuScreen()
            : base("")
        {
            // Create our menu entries.
            MenuEntry playGameMenuEntry = new MenuEntry("New Game");
            MenuEntry resumeGameMenuEntry = new MenuEntry("Resume Game");
            MenuEntry survivalMenuEntry = new MenuEntry("Survival");
            MenuEntry optionsMenuEntry = new MenuEntry("Options");
            MenuEntry highScoresMenuEntry = new MenuEntry("High Scores");

            // Hook up menu event handlers.
            playGameMenuEntry.Selected += PlayGameMenuEntrySelected;
            resumeGameMenuEntry.Selected += ResumeGameMenuEntrySelected;
            survivalMenuEntry.Selected += SurvivalMenuEntrySelected;
            optionsMenuEntry.Selected += OptionsMenuEntrySelected;
            highScoresMenuEntry.Selected += HighScoresMenuEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(resumeGameMenuEntry);
            MenuEntries.Add(playGameMenuEntry);
            MenuEntries.Add(survivalMenuEntry);
            MenuEntries.Add(optionsMenuEntry);
            MenuEntries.Add(highScoresMenuEntry);
        }
コード例 #2
0
 /// <summary>
 /// Allows the screen to create the hit bounds for a particular menu entry.
 /// </summary>
 protected virtual Rectangle GetMenuEntryHitBounds(MenuEntry entry)
 {
     // the hit bounds are the entire width of the screen, and the height of the entry
     // with some additional padding above and below.
     return new Rectangle(
         0,
         (int)entry.Position.Y - MenuEntryPadding,
         ScreenManager.GraphicsDevice.Viewport.Width,
         entry.GetHeight(this) + (MenuEntryPadding * 2));
 }