Hi, I followed the tutorial on http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/ to achieve a camera that follows my player sprite with zoom in/out functionality.
however, when I zoom in/out the camera seems to either slowly move away from the sprite whilst moving, I don't think I'm setting the position right, but I can't seem to figure out what it needs to be.
Here's some snippets if it helps
if (cam.Follow)
{
RectangleF temp = playerBoundingBox;
cam.Pos = new Vector2(
(temp.X + temp.Width / 2)*cam.Zoom,
temp.Y + temp.Height / 2) * cam.Zoom;
}
public Matrix get_transformation(GraphicsDevice graphicsDevice)
{
_transform =
// Add Zoom
Matrix.CreateScale(
new Vector3((_zoom * _zoom * _zoom),
(_zoom * _zoom * _zoom), 0))
// Add Camera Rotation
* Matrix.CreateRotationZ(_rotation)
// Add Camera Position
* Matrix.CreateTranslation(
new Vector3((graphicsDevice.Viewport.Width * 0.5f) - _pos.X,
(graphicsDevice.Viewport.Height * 0.5f) - _pos.Y,
0));
return _transform;
}
thank you in advance.