Description: This sample shows how to manage the transitions between different menus and gameplay states on Windows Phone. Sample Overview The sample implements a simple game flow with a main menu, an options screen, some actual gameplay, and a pause menu. It displays a loading screen in between the menus and gameplay, and uses a popup message box to confirm whether the user really wants to quit. The ScreenManager class is a reusable component that maintains a stack of one or more GameScreen instances. It coordinates the transitions from one screen to another, and takes care of routing user input to whatever screen is on top of the stack. Each screen class (including the actual gameplay, which is just another screen) derives from GameScreen. This provides Update, HandleInput, and Draw methods, plus some logic for managing the transition state. GameScreen does not actually implement any transition rendering effects, however: it merely provides information such as "you are currently 30% of the way through transitioning off," leaving it up to the derived screen classes to do something sensible with that information in their drawing code. This makes it easy for screens to implement different visual effects on top of the same underlying transition infrastructure. The Windows Phone version of this sample comes with a number of improvements to take into account special considerations for working with the device. InputState now contains fields for touch input. ScreenManager now supports Gestures and handles serialiazation and deserialization of game screens to account for exiting of the game through the user or the device. GameScreen also has Serialize and Deserialize methods that allow the subclasses to hook into the ScreenManager serialization system. |