1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- //-----------------------------------------------------------------------------
- // Game.cs
- //
- // Microsoft XNA Community Game Platform
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //-----------------------------------------------------------------------------
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- namespace 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
- {
- 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
- /// <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);
- }
- /// <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);
- }
- }
- }
|