Page 1 of 1

Zoom to center instead of top-left

Posted: Sun Jan 06, 2019 10:10 pm
by ITISTHEBKID
Hi, simple question with a presumably simple answer. How do I zoom to the center instead of the top left?
I have an XScale and YScale variable, and when things are drawn, they are drawn to the scale of these variables:

Code: Select all

love.graphics.draw(BG,deltaX,deltaY,0,XScale,YScale)
When this zooms, it zooms to the top left, which can be a little disorienting. How do I zoom to the center?

Re: Zoom to center instead of top-left

Posted: Sun Jan 06, 2019 10:40 pm
by pgimeno

Code: Select all

local w, h = BG:getDimensions()
love.graphics.draw(BG, deltaX, deltaY, 0, XScale, YScale, w/2, h/2)
This will have the side effect of drawing the image with its centre at the given coordinates, rather than its top left.