Beispiel #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.SetRenderTarget(renderTarget);

            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise);

            //sm.Draw(gameTime, spriteBatch);

            currentState.Draw(gameTime, spriteBatch);

            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);

            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise);


            int width = Window.ClientBounds.Height * (800 / 600);

            //Debug.WriteLine("width = " + width);
            //Debug.WriteLine("height = " + Window.ClientBounds.Height);

            Rectangle rect = new Rectangle((Window.ClientBounds.Width - width) / 2, 0, width, Window.ClientBounds.Height);

            if (!graphics.IsFullScreen)
            {
                rect = new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height);
            }

            spriteBatch.Draw(renderTarget, rect,
                             camera.DrawToRectangle, Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }