This project has moved and is read-only. For the latest updates, please go here.

A good camera for Farseer?

Topics: User Forum
Jun 20, 2011 at 9:29 PM


I've been using some old Camera2D class for my game, but I can't seem to solve this annoying offset with physics and graphics. It works well on some resolutions (like 800x600) but starts to gain offset on others (like 1024x768). I really can't find a reason for this, my drawing code isn't that complicated.

So, what camera classes are you using? Have you made your own, or is there a good one out there?


Jun 25, 2011 at 5:54 PM

i edited a very basic camera class i found somewhere

don't forgett to do this: (or whatever you use to scale physics down)

public Vector2 Position
                return Cube.Body.Position * FarseerScale.PixelsPerUnit;
                Cube.Body.Position = value / FarseerScale.PixelsPerUnit;
a basic camera transform:
ScreenCenter = new Vector2(_viewportWidth / 2, _viewportHeight / 2);
Origin = ScreenCenter / Scale;
Transform = Matrix.Identity *
                        Matrix.CreateTranslation(-Position.X, -Position.Y, -1f) *
                        Matrix.CreateRotationZ(Rotation) *
                        Matrix.CreateTranslation(Origin.X, Origin.Y, 0) *
                        Matrix.CreateScale(new Vector3(Scale));