Zoom to center instead of top-left

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
ITISTHEBKID
Prole
Posts: 8
Joined: Sun Nov 11, 2018 9:45 pm

Zoom to center instead of top-left

Post by ITISTHEBKID » Sun Jan 06, 2019 10:10 pm

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?

User avatar
pgimeno
Party member
Posts: 2211
Joined: Sun Oct 18, 2015 2:58 pm

Re: Zoom to center instead of top-left

Post by pgimeno » Sun Jan 06, 2019 10:40 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests