/// <summary> /// Tells each screen to draw itself. /// </summary> public override void Draw(GameTime gameTime) { foreach (GameScreen screen in _screens) { if (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.TransitionOff || screen.ScreenState == ScreenState.Active) { screen.PreDraw(gameTime); GraphicsDevice.SetRenderTarget(null); } } int transitionCount = 0; foreach (GameScreen screen in _screens) { if (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.TransitionOff) { ++transitionCount; if (_transitions.Count < transitionCount) { PresentationParameters _pp = GraphicsDevice.PresentationParameters; _transitions.Add(new RenderTarget2D(GraphicsDevice, _pp.BackBufferWidth, _pp.BackBufferHeight, false, SurfaceFormat.Color, _pp.DepthStencilFormat, _pp.MultiSampleCount, RenderTargetUsage.DiscardContents)); } GraphicsDevice.SetRenderTarget(_transitions[transitionCount - 1]); GraphicsDevice.Clear(Color.Transparent); screen.Draw(gameTime); GraphicsDevice.SetRenderTarget(null); } } GraphicsDevice.Clear(Color.Black); transitionCount = 0; foreach (GameScreen screen in _screens) { if (screen.ScreenState == ScreenState.Hidden) { continue; } if (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.TransitionOff) { SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); SpriteBatch.Draw(_transitions[transitionCount], Vector2.Zero, Color.White * screen.TransitionAlpha); SpriteBatch.End(); ++transitionCount; } else { screen.Draw(gameTime); } } _input.Draw(); }