Just like chris already said, depending on the size of the screen, the amount of pixels displayed vary. So use love.graphics.getHeight() to get the actual height of the screen in pixels.
Then you want to make sure, your object always stays at the same place, regardless of your screen size. You can achieve that if you subtract some pixels from the actual height of the screen (known from getHeight()
). Something like this:
screenHeight = love.graphics.getHeight()
objectPositionY = screenHeight - 100
objectHeight = 10
But as you just mentioned in one of the comments above, on 'smaller' window sizes the object won't get displayed at all. That happens, if the screenHeight
is smaller than the 100 pixels you subtract, in which case the object is displayed above/outside the visible screen, of course. But if you really want to create a game using such small windows, you can try something like this:
screenHeight = love.graphics.getHeight()
objectPositionY = screenHeight * 0.9
objectHeight = screenHeight * 0.05
This way the object always says on the exact same spot depending on the screenHeight, where 0
is the top and 1
is the bottom of the screen. Oh, and of course, you can do the same for the screenWidth
as well.
But overall, you maybe should limit the minimum size to something useful.
And for the sake of completeness, if you want to create a game for multiple platforms (especially Android) using highDPI, you might want to consider love.window.getPixelScale as well!