123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #region File Description
- //-----------------------------------------------------------------------------
- // Game.cs
- //
- // Microsoft XNA Community Game Platform
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //-----------------------------------------------------------------------------
- #endregion
- #region Using Statements
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- #endregion
- namespace Microsoft.Xna.Samples.GameStateManagement
- {
- /// <summary>
- /// Sample showing how to manage different game states, with transitions
- /// between menu screens, a loading screen, the game itself, and a pause
- /// menu. This main game class is extremely simple: all the interesting
- /// stuff happens in the ScreenManager component.
- /// </summary>
- public class GameStateManagementGame : Game
- {
- #region Fields
- GraphicsDeviceManager graphics;
- ScreenManager screenManager;
- #if ZUNE
- int BufferWidth = 272;
- int BufferHeight = 480;
- #elif IPHONE
- int BufferWidth = 320;
- int BufferHeight = 480;
- #else
- int BufferWidth = 272;
- int BufferHeight = 480;
- #endif
- #endregion
- #region Initialization
- /// <summary>
- /// The main game constructor.
- /// </summary>
- public GameStateManagementGame()
- {
- Content.RootDirectory = "Content";
- graphics = new GraphicsDeviceManager(this);
- graphics.PreferredBackBufferWidth = BufferWidth;
- graphics.PreferredBackBufferHeight = BufferHeight;
- // Create the screen manager component.
- screenManager = new ScreenManager(this);
- Components.Add(screenManager);
- // Activate the first screens.
- screenManager.AddScreen(new BackgroundScreen(), null);
- screenManager.AddScreen(new MainMenuScreen(), null);
- }
- #endregion
- #region Draw
- /// <summary>
- /// This is called when the game should draw itself.
- /// </summary>
- protected override void Draw(GameTime gameTime)
- {
- graphics.GraphicsDevice.Clear(Color.Black);
- // The real drawing happens inside the screen manager component.
- base.Draw(gameTime);
- }
- #endregion
- }
- }
|