/// <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(); }
protected override void Draw(GameTime gameTime) { _screenManager.Draw(gameTime); _input.Draw(_spriteBatch); #if WINDOWS if (_showFps) { _counter.Draw(_spriteBatch); } #endif base.Draw(gameTime); }
/// <summary> /// tell each Screen to Draw itself /// </summary> /// <param name="gameTime"></param> public override void Draw(GameTime gameTime) { Game.GraphicsDevice.Clear(Color.Black); mWindowManager.Draw(gameTime); mInput.Draw(gameTime); lock ( mScreens ) { foreach (GameScreen screen in mScreens.Values) { if (screen.ScreenState == EScreenState.Hidden) { continue; } screen.Draw(gameTime); } } }
protected override void Draw(GameTime gameTime) { 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(0, BlendState.AlphaBlend); if (screen is PhysicsDemoScreen) { Vector2 position = Vector2.Lerp(_menuScreen.PreviewPosition, new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height) / 2f, 1f - screen.TransitionPosition); _spriteBatch.Draw(_transitions[transitionCount], position, null, Color.White * Math.Min(screen.TransitionAlpha / 0.2f, 1f), 0f, new Vector2(_transitions[transitionCount].Width, _transitions[transitionCount].Height) / 2f, 0.5f + 0.5f * (1f - screen.TransitionPosition), SpriteEffects.None, 0f); } else { _spriteBatch.Draw(_transitions[transitionCount], Vector2.Zero, Color.White * screen.TransitionAlpha); } _spriteBatch.End(); transitionCount++; } else { screen.Draw(gameTime); } } _input.Draw(_spriteBatch); #if WINDOWS if (_showFPS) { _counter.Draw(_spriteBatch); } #endif base.Draw(gameTime); }