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 ??
Resolution problem
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Resolution problem
You can use a canvas with resolution of 800x600 and then scale it to fit any screen, here's an example:
and here's the documentation:
https://love2d.org/wiki/Canvas
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
https://love2d.org/wiki/Canvas
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Nikki and 4 guests