Resolution problem

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
white hawk
Prole
Posts: 2
Joined: Wed Mar 01, 2017 6:44 pm

Resolution problem

Post 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 ??
User avatar
alberto_lara
Party member
Posts: 372
Joined: Wed Oct 30, 2013 8:59 pm

Re: Resolution problem

Post 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
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Nikki and 4 guests