Camera with Physics

Feb 23, 2008 at 9:55 PM
Hey. When I finally got my physics working, I had to take away the camera, Now I'm having troubles as I have tried to add a camera back in. In my draw code on the gameplay screen class I draw like this:

map.Draw(spriteBatch, camera.WorldToScreen(new Vector2(0,0)));

objects.Draw(spriteBatch, camera);

Then in my objectmanager, it just loops through all objects and passes the spritebatch and camera. Here is an example of Player's Draw
public void Draw(SpriteBatch batch, Camera2D cam)
{
Vector2 pos = cam.WorldToScreen(Physics.Geometry.Position);
batch.Draw(Texture, pos, null, Color.White, Physics.Geometry.Rotation, new Vector2(Texture.Width / 2f, Texture.Height / 2f), 1, SpriteEffects.None, 0);
}

This draw all the object proportionally, but when I press F1 for debug view of collision, I see that it draws in world position and not screen position. Here is a screenshot: http://img86.imageshack.us/img86/6608/buged2.png
I could just pass the camera through the SimulatorView I realize, but would that work properly?

Also, the camera class to convert is just this:
public Vector2 WorldToScreen(Vector2 nodeWorldPosition)
{
// apply translation
Vector2 finalPosition = nodeWorldPosition - cameraPosition;
return finalPosition;
}
public Vector2 ScreenToWorld(Vector2 nodeScreenPosition)
{
// apply translation
Vector2 finalPosition = nodeScreenPosition + cameraPosition;
return finalPosition;
}


Is this correct for shifting positions?