The loading screen coordinates transitions between the menu system and the game itself. More...
Public Member Functions | |
| override void | Update (GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) |
| Updates the loading screen. | |
| override void | Draw (GameTime gameTime) |
| Draws the loading screen. | |
Static Public Member Functions | |
| static void | Load (ScreenManager screenManager, bool loadingIsSlow, PlayerIndex?controllingPlayer, params GameScreen[] screensToLoad) |
| Activates the loading screen. | |
The loading screen coordinates transitions between the menu system and the game itself.
Definition at line 17 of file MontyHallLoadingScreen.cs.
| override void MontyHallGame.MontyHallLoadingScreen.Draw | ( | GameTime | gameTime | ) | [virtual] |
Draws the loading screen.
Reimplemented from NewGamePhysics.StateManager.GameScreen.
Definition at line 102 of file MontyHallLoadingScreen.cs.
00103 { 00104 // If we are the only active screen, that means all the previous screens 00105 // must have finished transitioning off. We check for this in the Draw 00106 // method, rather than in Update, because it isn't enough just for the 00107 // screens to be gone: in order for the transition to look good we must 00108 // have actually drawn a frame without them before we perform the load. 00109 if ((ScreenState == ScreenState.Active) && 00110 (ScreenManager.GetScreens().Length == 1)) 00111 { 00112 otherScreensAreGone = true; 00113 } 00114 00115 // The gameplay screen takes a while to load, so we display a loading 00116 // message while that is going on, but the menus load very quickly, and 00117 // it would look silly if we flashed this up for just a fraction of a 00118 // second while returning from the game to the menus. This parameter 00119 // tells us how long the loading is going to take, so we know whether 00120 // to bother drawing the message. 00121 if (loadingIsSlow) 00122 { 00123 SpriteBatch spriteBatch = ScreenManager.SpriteBatch; 00124 SpriteFont font = ScreenManager.Fonts["game"]; 00125 00126 const string message = "Loading..."; 00127 00128 // Center the text in the viewport. 00129 Viewport viewport = ScreenManager.GraphicsDevice.Viewport; 00130 Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height); 00131 Vector2 textSize = font.MeasureString(message); 00132 Vector2 textPosition = (viewportSize - textSize) / 2; 00133 00134 Color color = new Color(255, 255, 255, TransitionAlpha); 00135 00136 // Draw the text. 00137 spriteBatch.Begin(); 00138 spriteBatch.DrawString(font, message, textPosition, color); 00139 spriteBatch.End(); 00140 } 00141 }
| static void MontyHallGame.MontyHallLoadingScreen.Load | ( | ScreenManager | screenManager, | |
| bool | loadingIsSlow, | |||
| PlayerIndex? | controllingPlayer, | |||
| params GameScreen[] | screensToLoad | |||
| ) | [static] |
Activates the loading screen.
Definition at line 48 of file MontyHallLoadingScreen.cs.
00051 { 00052 // Tell all the current screens to transition off. 00053 foreach (GameScreen screen in screenManager.GetScreens()) 00054 screen.ExitScreen(); 00055 00056 // Create and activate the loading screen. 00057 MontyHallLoadingScreen loadingScreen = new MontyHallLoadingScreen(screenManager, 00058 loadingIsSlow, 00059 screensToLoad); 00060 00061 screenManager.AddScreen(loadingScreen, controllingPlayer); 00062 }
| override void MontyHallGame.MontyHallLoadingScreen.Update | ( | GameTime | gameTime, | |
| bool | otherScreenHasFocus, | |||
| bool | coveredByOtherScreen | |||
| ) | [virtual] |
Updates the loading screen.
Reimplemented from NewGamePhysics.StateManager.GameScreen.
Definition at line 72 of file MontyHallLoadingScreen.cs.
00074 { 00075 base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); 00076 00077 // If all the previous screens have finished transitioning 00078 // off, it is time to actually perform the load. 00079 if (otherScreensAreGone) 00080 { 00081 ScreenManager.RemoveScreen(this); 00082 00083 foreach (GameScreen screen in screensToLoad) 00084 { 00085 if (screen != null) 00086 { 00087 ScreenManager.AddScreen(screen, ControllingPlayer); 00088 } 00089 } 00090 00091 // Once the load has finished, we use ResetElapsedTime to tell 00092 // the game timing mechanism that we have just finished a very 00093 // long frame, and that it should not try to catch up. 00094 ScreenManager.Game.ResetElapsedTime(); 00095 } 00096 }
1.6.2