Created
March 9, 2018 15:33
-
-
Save drhayes/14bdc22ea1fbd4d4380aa92c615a93d9 to your computer and use it in GitHub Desktop.
LÖVE rescale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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