/// <summary> /// Draws the message box /// </summary> public override void Draw(GameTime gameTime) { // Darken any screens drawn beneath this popup ScreenManager.FadeBackBufferToBlack(ScreenManager.SpriteBatch, TransitionAlpha * 2 / 3); // Center the message text in the viewport Viewport viewport = ScreenManager.GraphicsDevice.Viewport; Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height); Vector2 textSize = ScreenManager.Font.MeasureString(message); Vector2 textPosition = (viewportSize - textSize) / 2; // Inluce a border somewhat larger than the text itself int hPad = (int)textSize.X; int vPad = (int)textSize.Y; Rectangle backgroundRectangle = new Rectangle((int)textPosition.X - 32, (int)textPosition.Y - 32, viewport.Width - 2 * ((int)textPosition.X - 32), (int)textPosition.Y + 32); // Fade the popup alpha during transition Color color = new Color(255, 255, 255, TransitionAlpha); ScreenManager.SpriteBatch.Begin(); // Draw the background rectangle ScreenManager.SpriteBatch.Draw(gradientTexture, backgroundRectangle, color); // Draw the message box text ScreenManager.SpriteBatch.DrawString(ScreenManager.Font, message, textPosition, color); ScreenManager.SpriteBatch.End(); }
/// <summary> /// Draws the game. /// </summary> public override void Draw(GameTime gameTime) { // Draw the water waterManager.Draw(camera, DrawScene); // Now draw the scene itself DrawScene(); // If the game is transitioning on or off, fade it out to black if (TransitionPosition > 0) { ScreenManager.FadeBackBufferToBlack(ScreenManager.SpriteBatch, 255 - TransitionAlpha); } }