[Solved] Problem with graphics.getDimensions on Android
Posted: Sun Dec 11, 2022 2:34 pm
Hello everyone !
I'm facing a small problem with the love.graphics.getDimensions function on Android, I wrote myself a small script to resize the game according to the resolution which roughly looks like this:
On PC it works very well, the problem occurs on Android where the navigation bar (the Home, Return buttons, etc.) does not always take the same time to hide and therefore I sometimes get the screen size without the bar and other times with the bar, which means that once in two the buttons, joystick, etc. find themselves out of step with the rest of the display (I use GOOI for the GUI elements).
I tried several hacks but without success, if anyone has a solution to this problem that would be great!
I'm facing a small problem with the love.graphics.getDimensions function on Android, I wrote myself a small script to resize the game according to the resolution which roughly looks like this:
Code: Select all
local lg = love.graphics
Display = {
size = {
w = WIN_W, -- Where WIN_* is the original game size
h = WIN_H
},
scale = {
x = 1,
y = 1
}
}
function Display:render(drawable, ...)
lg.push(); lg.scale(self.scale.x, self.scale.y)
drawable(...); lg.pop()
end
function Display:resize()
local size, scale = self.size, self.scale
size.w, size.h = lg.getDimensions()
scale.x = size.w / WIN_W
scale.y = size.h / WIN_H
end
I tried several hacks but without success, if anyone has a solution to this problem that would be great!