love.graphics.scale() and screen positions
Posted: Sat Jan 26, 2013 11:40 pm
Hullo there!
I've looked around on the forums using the search function, to no avail...
My question is, how do I find the middle of the screen after applying love.graphics.scale?
I would have thought that you can just apply the values that you've used in love.graphics.scale() to the screens X and Y positions in some way or other...
Example:
Please help me, love2d forums, you're my only hope! (apart from stack overflow)
I've looked around on the forums using the search function, to no avail...
My question is, how do I find the middle of the screen after applying love.graphics.scale?
I would have thought that you can just apply the values that you've used in love.graphics.scale() to the screens X and Y positions in some way or other...
Example:
Code: Select all
function love.load()
screenHeight = love.graphics.getScreenHeight()
screenWidth = love.graphics.getScreenWidth()
scale = 0.3
-- something LIKE this:
middleScreenHeight = screenHeight/2 * scale
middleScreenWidth = screenWidth/2 * scale
end
function love.draw()
love.graphics.scale(scale, scale)
love.graphics.setColor(255, 0, 0, 255)
-- Draws the rectangle to the center of the screen
love.graphics.rectangle(middleScreenHeight, middleScreenWidth, 32, 32)
end