How does the debugView work and how do I implement it

Oct 18, 2007 at 1:11 PM
Just like the title says, how can I implement the debugView from the demos into my own farseer project and get it to work properly.
Coordinator
Oct 19, 2007 at 11:35 AM
Edited Oct 19, 2007 at 11:38 AM
First you need to copy PhysicsSimulatorView.cs from the samples, into your own project.

Here is the code for displaying the PhysicsSimulatorView:

public class MyGame : Game
{
private PhysicsSimulator physicsSimulator;
private PhysicsSimulatorView physicsSimulatorView;
private ContentManager contentManager;
private GraphicsDeviceManager graphics;
private SpriteBatch spriteBatch;

public MyGame()
{
contentManager = new ContentManager(this.Services);
graphics = new GraphicsDeviceManager(this);
spriteBatch = new SpriteBatch(graphics);
physicsSimulator = new PhysicsSimulator(new Vector2(0, 150));
// Set all your physicsSimulator properties here
physicsSimulatorView = new PhysicsSimulatorView(physicsSimulator);
}

public override void LoadGraphicsContent(bool loadAllContent)
{
physicsSimulatorView.LoadGraphicsContent(graphics.GraphicsDevice, contentManager);
}

public override void Draw(GameTime gameTime)
{
spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
physicsSimulatorView.Draw(spriteBatch);
spriteBatch.End();
}
}

I'm not 100% sure if i got everything needed. I did not tests this and most of it is from memory.
Good luck with your game.
Oct 20, 2007 at 4:36 AM
Thanks genbox, that worked fine. I actually use a custom transformation on the spritebatch to implement my zooming/panning/rotating camera and it worked just fine.