Page 1 of 1
Resolution problem
Posted: Wed Mar 01, 2017 6:56 pm
by white hawk
hey guys, i created a simple game 800x600 resolution it works fine until i run it in full screen where the rest of the screen is black, the same problem occurred when i port the game to android where the screen size vary according to the phone screen resolution.
any solutions ??
Re: Resolution problem
Posted: Fri Mar 03, 2017 3:58 pm
by alberto_lara
You can use a canvas with resolution of 800x600 and then scale it to fit any screen, here's an example:
Code: Select all
function love.load()
canvas = love.graphics.newCanvas(320, 240)-- small canvas (use 800 and 600 here)
-- calculate scaling:
scaleX = love.graphics.getWidth() / canvas:getWidth()
scaleY = love.graphics.getHeight() / canvas:getHeight()
end
function love.update(dt)
end
function love.draw()
love.graphics.setColor(255, 255, 255)
love.graphics.setCanvas(canvas)
-- draw your stuff here:
love.graphics.setColor(0, 0, 0)
love.graphics.rectangle("fill", 0, 0, canvas:getWidth(), canvas:getHeight())
love.graphics.setColor(255, 255, 255)
love.graphics.circle("fill", 100, 100, 30)
love.graphics.print("scaled text!")
love.graphics.setCanvas()
-- draw the entire canvas, scaled:
love.graphics.clear()
love.graphics.draw(canvas, 0, 0, 0, scaleX, scaleY)
end
and here's the documentation:
https://love2d.org/wiki/Canvas