12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- //-----------------------------------------------------------------------------
- // MainMenuScreen.cs
- //
- // Microsoft XNA Community Game Platform
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //-----------------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using GameStateManagement;
- using Microsoft.Xna.Framework;
- namespace CatapultGame
- {
- class MainMenuScreen : MenuScreen
- {
- 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);
- }
- protected override void UpdateMenuEntryLocations()
- {
- base.UpdateMenuEntryLocations();
- foreach (var entry in MenuEntries)
- {
- Vector2 position = entry.Position;
- position.Y += 60;
- entry.Position = position;
- }
- }
- /// <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();
- }
- }
- }
|