//----------------------------------------------------------------------------- // 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 { /// /// 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. /// 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 /// /// The main game constructor. /// 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); } /// /// This is called when the game should draw itself. /// protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.Black); // The real drawing happens inside the screen manager component. base.Draw(gameTime); } } }