Hello everyone!
I have a camera class (below) that is attached to an object, and runs the “Update” method every frame. I need to scale the camera from the center to create a zooming in effect, but I don’t want to have to change the game’s resolution or render more things than I need to. Right now I have the below matrix being passed into the SpriteBatch’s transformationMatrix, with the pivot at Vec2(0.5, 0.5) and the scale at Vec2(1, 1), rotation at 0 and the position at Vec2(0, 0). But I can’t manage to scale the camera from the center, even though it does work for Spritebatch.Draw()
public override void Update()
{
Matrix = Matrix.CreateTranslation(LinkedObject.Pivot.X, LinkedObject.Pivot.Y, 0) * Matrix.CreateScale(new Vector3(LinkedObject.Size.X, LinkedObject.Size.Y, 1)) * Matrix.CreateRotationZ(MathHelper.ToRadians(LinkedObject.Rotation));
Matrix.Translation = -new Vector3(LinkedObject.Position.X - (Settings.Window.GameResolution.X * LinkedObject.Pivot.X), LinkedObject.Position.Y - (Settings.Window.GameResolution.Y * LinkedObject.Pivot.Y), 0);
}
Any help would be appreciated!