Hi, I've followed the code from the simple samples to get the debugview working, and it does.. kinda.
I can get the performance panel showing, and it shows that there is 1 Body, which is correct. What I am trying to do, is to get the outline of the shape/polygon showing, similar to how it was in the previous FP 2.1.
I think the problem is due to my camera, but I'm unsure. It always worked fine in the previous versions, where you just passed it a reference to the spritebatch. Currently, I can't see any outlines of shapes or polygons, no matter whether I used the Flag.Shape
or Flag.PolygonPoints, but the display panel always shows in the top-left corner, regardless of where I move the camera. I think this may be the problem, as it is moving the shapes/polygons drawn with the debugview along with the camera, so they are always
out of view?
The code I use for my camera is from here: http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/
Here's the code I'm using for DebugView:
//Load Debug View
DebugView.DefaultLineWidth = 10f;
DebugView.DefaultShapeColor = new Color(255, 0, 0);
DebugView.StaticShapeColor = new Color(255, 0, 0);
//My background is orange, and objects/shapes are black,
// so I wanted to change the colors to red to be able to see them..
/// Draws the gameplay screen.
public override void Draw(GameTime gameTime)
// This game has a blue background. Why? Because!
Color.Orange, 0, 0);
// Our player and enemy are both actually just text strings.
SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
// DRAW LEVEL //
foreach (Layer layer in level.Layers)
Vector2 oldcameraposition = camera._pos;
camera._pos *= layer.ScrollSpeed;
if (layer.Name == "DEBUG")
Matrix proj = Matrix.CreateOrthographic(50 * ScreenManager.GraphicsDevice.Viewport.AspectRatio, 50, 0, 1);
Matrix view = Matrix.Identity;
DebugView.RenderDebugData(ref proj, ref view);
camera._pos = oldcameraposition;
I think I need to transform the debugview shapes/polygons according to the cameras transform, so that they stay in place while the camera moves. But because the new RenderDebugData requires Matrix's and not a SpriteBatch, I'm kinda stuck.
Jan 10, 2011 at 3:14 AM
The performance panel is drawn using a matrix created inside the debug view. That is why you see it all the time in the upper left corner.
Your problem is the matrix you send to the DebugViewXNA class. You should take a look at the Camera used in the SimpleSamples and how it is used to draw the debug view.