1. I don't understand how to choose the resolution for the mobile platform
As far as I know, there is a usedpiscale property in conf.lua, and as long as it is true, automatic DPI scaling works. I know that DPI is the density of dots per inch, but how should this affect programming? I can't create a window using DPI. For example, in pixels: 2160 x 1080, and in DPI? Does it make sense to set the window size in setMode in the scripts? My android smartphone has a resolution of 2160 x 1080, so the game window should be the same, right?
2. When running the app on android via Love for Android, it always runs in landscape orientation, although I need portrait orientation.
I rummaged through the forum, many advise to make the height more than the width, so this does not work. I went through a bunch of different sizes in setMode, and output love.window.getDisplayOrientation(), it has always been a "Landscape". There is a trick, you can set resizable = false, then the window is displayed in portrait mode, but if you output the display orientation using love.window.getDisplayOrientation (), then still writes "Landscape".
3. Why does the window not adjust to the screen?
When creating a window with a size of 1080x2160 for a screen with a resolution of 1080x2160, I expect that the window will fill the screen, but the portrait window is displayed in landscape mode, and only a small part of it is on the screen.
Let's simulate the situation: You create a simple project: A smartphone app, with a black background, and 4 box in the corners, and in the middle "Hello world". The question is, what should I write in my code and conf. lua, in order for this application to work correctly on all modern android smartphones?
Вот код:
Code: Select all
SCREEN_WIDTH = 420
SCREEN_HEIGHT = 840
font = love.graphics.newFont("flappy.ttf", 34)
local quadSize = 32
local quadColor = {1, 0.75, 0}
local textColor = {0.44, 0, 1}
function love.load()
love.window.setMode(SCREEN_WIDTH,SCREEN_HEIGHT,{
fullscreen = false,
vsync = 1,
resizable = true
})
end
function love.draw()
love.graphics.setColor(quadColor)
love.graphics.rectangle("fill",20,20,quadSize,quadSize)
love.graphics.rectangle("fill",368,20,quadSize,quadSize)
love.graphics.rectangle("fill",20,788,quadSize,quadSize)
love.graphics.rectangle("fill",368,788,quadSize,quadSize)
love.graphics.setColor(textColor)
love.graphics.setFont(font)
love.graphics.printf("Hello World", 0, SCREEN_HEIGHT/2, SCREEN_WIDTH, "center")
end
Sorry for the spelling, my language is not English, this is an auto-translator