1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #region File Description
- //-----------------------------------------------------------------------------
- // MainMenuScreen.cs
- //
- // Microsoft XNA Community Game Platform
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //-----------------------------------------------------------------------------
- #endregion
- #region Using Statements
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using GameStateManagement;
- using Microsoft.Xna.Framework;
- #endregion
- namespace CatapultGame
- {
- class MainMenuScreen : MenuScreen
- {
- #region Initialization
- public MainMenuScreen()
- : base(String.Empty)
- {
- IsPopup = true;
- // Create our menu entries.
- MenuEntry startGameMenuEntry = new MenuEntry("Play");
- MenuEntry exitMenuEntry = new MenuEntry("Exit");
- // Hook up menu event handlers.
- startGameMenuEntry.Selected += StartGameMenuEntrySelected;
- exitMenuEntry.Selected += OnCancel;
- // Add entries to the menu.
- MenuEntries.Add(startGameMenuEntry);
- MenuEntries.Add(exitMenuEntry);
- }
- #endregion
- #region Overrides
- protected override void UpdateMenuEntryLocations()
- {
- base.UpdateMenuEntryLocations();
- foreach (var entry in MenuEntries)
- {
- Vector2 position = entry.Position;
- position.Y += 60;
- entry.Position = position;
- }
- }
- #endregion
- #region Event Handlers for Menu Items
- /// <summary>
- /// Handles "Play" menu item selection
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void StartGameMenuEntrySelected(object sender, EventArgs e)
- {
- ScreenManager.AddScreen(new InstructionsScreen(), null);
- }
- /// <summary>
- /// Handles "Exit" menu item selection
- /// </summary>
- ///
- protected override void OnCancel(PlayerIndex playerIndex)
- {
- ScreenManager.Game.Exit();
- }
- #endregion
- }
- }
|