/// <summary> /// Draw the world. /// </summary> public override void Draw() { Matrix tform = Camera.Transform; // Draw entities. SpriteBatchPush(); DrawChildren(m_spriteBatch); SpriteBatchPop(); if (m_debugView != null) { // Debug drawing. Matrix debugMatrix = Matrix.CreateScale(k_invPhysicsScale) * tform; m_debugView.RenderDebugData(ref m_projection, ref debugMatrix); } // Draw HUD. HUD.Draw(); if (fade) { FadeOut.fadeOut(0.3f); } FadeOut.Draw(m_spriteBatch); //Draw popup if (m_popUp != null) { m_popUp.Draw(); } }
protected override void Draw(GameTime gameTime) { // Matrix projection und Matrix view for PhysicsDebugView // // Calculate the projection and view adjustments for the debug view projection = Matrix.CreateOrthographicOffCenter(0f, graphics.GraphicsDevice.Viewport.Width / MeterInPixels, graphics.GraphicsDevice.Viewport.Height / MeterInPixels, 0f, 0f, 1f); view = Matrix.Identity; // Everything between penumbra.BeginDraw and penumbra.Draw will be // lit by the lighting system. penumbra.BeginDraw(); GraphicsDevice.Clear(Color.White); // Draw items affected by lighting here ... spriteBatch.Begin(SpriteSortMode.Deferred, null); // Draw the texture of the physics body spriteBatch.Draw(tBodyTexture, ConvertUnits.ToDisplayUnits(tBody.Position), null, Color.Tomato, tBody.Rotation, tBodyOrigin, 1f, SpriteEffects.None, 0); spriteBatch.End(); penumbra.Draw(gameTime); // Draw items NOT affected by lighting here ... (UI, for example) spriteBatch.Begin(SpriteSortMode.Deferred, null); // Draw Shadow spriteBatch.DrawString(Font, "[F2] Toggle the visibility of the physics shape." + "\n" + "[Left Mouse Button] Manipulate the physics object.", new Vector2(10, 400), Color.Black); // Draw Default spriteBatch.DrawString(Font, "[F2] Toggle the visibility of the physics shape." + "\n" + "[Left Mouse Button] Manipulate the physics object.", new Vector2(9, 399), Color.Yellow); spriteBatch.End(); // Draw the physics debug view PhysicsDebugView.RenderDebugData(ref projection); base.Draw(gameTime); }