Screen resolution across multiple Android device

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Trafitto
Prole
Posts: 4
Joined: Fri Jan 26, 2018 4:06 pm
Contact:

Screen resolution across multiple Android device

Post by Trafitto »

Hi!

I'm developing a simple game with Love the target platform is Android with the screen orientation to portrait but I can't imagine how to manage the scale of the screen.

Currently when I try the apk all the images are drawn in the lower left corner.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Screen resolution across multiple Android device

Post by pgimeno »

I think this should work:

Code: Select all

function love.draw()
  do
    local scale = love.graphics.getWidth() / myGameScreenWidth
    local scaleY = love.graphics.getHeight() / myGameScreenHeight
    if scaleY < scale then scale = scaleY end
    love.graphics.scale(scale)
  end
  -- the rest of your love.draw goes here
end
You may need to translate too, to centre the game screen.

However, if you use quads, see this caveat:

https://love2d.org/wiki/Quad

You may also want to use portland (a portrait/landscape handling library): https://love2d.org/forums/viewtopic.php?f=5&t=84810
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

Re: Screen resolution across multiple Android device

Post by PGUp »

Use libraries like CScreen if you are working with touch position
-
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 3 guests