Skip to content

Instantly share code, notes, and snippets.

@drhayes
Created March 9, 2018 15:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drhayes/14bdc22ea1fbd4d4380aa92c615a93d9 to your computer and use it in GitHub Desktop.
Save drhayes/14bdc22ea1fbd4d4380aa92c615a93d9 to your computer and use it in GitHub Desktop.
LÖVE rescale
function Camera:resize(w, h)
local dw, dh = config.graphics.width, config.graphics.height
local x, y = w / dw, h / dh
local scale = math.min(x, y)
local width, height = dw * scale, dh * scale
self.camera:setScale(scale)
local wPadding, hPadding = (w - width) / 2, (h - height) / 2
self.padding = {
x = wPadding, y = hPadding
}
self.camera:setWindow(wPadding, hPadding, width, height)
Signal.emit('cameraResize')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment