Code: Select all
button = {}
function button.spawn(x, y, text)
table.insert(button, {x = x, y = y, text = text})
end
function button.draw()
for i, v in ipairs(button) do
love.graphics.setColor(255,255,255)
love.graphics.print(v.text, v.x, v.y)
end
end
Code: Select all
if gamestate == "paused" then
button.draw()
love.graphics.getFont("Android.ttf")
local width = font:getWidth("Start") --gets the width of the argument in pixels for this font
button.spawn(windowWidth/2-width/2, windowHeight/4, "Start")
local width = font:getWidth("Settings") --gets the width of the argument in pixels for this font
button.spawn(windowWidth/2-width/2, windowHeight/2, "Settings")
local width = font:getWidth("Quit") --gets the width of the argument in pixels for this font
button.spawn(windowWidth/2-width/2, windowHeight/4+windowHeight/2, "Quit")
print(button)
end
Loading up the game prints like so:
Which is absolutely fine. Although, when i change the window size, it appears like so...
I don't understand why the old text stays, but doesn't update.
And by the way, yes, I do understand that i will need to update the 'windowHeight' and font size variable to come in scale with the window but I just haven't got around to doing it yet.
Thanks a lot,
Olee