I tried:
Code: Select all
love.graphics.draw(map, 0, 0, 0, 1, 1, map:getWidth()/2, map:getWidth()/2)
PS: I need this urgently since I have a project due tomorrow that involves this.
Code: Select all
love.graphics.draw(map, 0, 0, 0, 1, 1, map:getWidth()/2, map:getWidth()/2)
I want to center it in the middle of the screen so that the margins on all sides are equal. I'm using my application in fullscreen mode, if that makes a difference. Also, the map takes up most of the screen, but the margins are all weird. If there's a way to center margins, that's what I need.Pebsie wrote:
I'm still not entirely sure what you mean D:Tyler821 wrote:I want to center it in the middle of the screen so that the margins on all sides are equal. I'm using my application in fullscreen mode, if that makes a difference. Also, the map takes up most of the screen, but the margins are all weird. If there's a way to center margins, that's what I need.Pebsie wrote:
Code: Select all
love.graphics.draw(map, love.graphics.getWidth()/2, love.graphics.getHeight()/2, 0, 1, 1, map:getWidth()/2, map:getWidth()/2)
Oh, I thought I would only need either offset or position. -facepalm- Thanks!DaedalusYoung wrote:You need the window / screen dimensions. In your code, you center the image, based on its width and height, around position 0,0. That will place the image's centre at the top left.
Do something like this:Code: Select all
love.graphics.draw(map, love.graphics.getWidth()/2, love.graphics.getHeight()/2, 0, 1, 1, map:getWidth()/2, map:getWidth()/2)
Code: Select all
function love.draw()
love.graphics.setColor(255,255,255,255)
love.graphics.circle("fill", love.graphics.getWidth()/2, love.graphics.getHeight()/2, love.graphics.getHeight()/2)
end
Code: Select all
function love.draw()
love.graphics.setColor(255,255,255,255)
love.graphics.draw(map, love.graphics.getWidth()/2 - map:getWidth()/2, love.graphics.getHeight()/2 - map:getHeight()/2)
end
Users browsing this forum: Ahrefs [Bot], Google [Bot], Majestic-12 [Bot] and 2 guests