When I pause the game with to escape key I would text to come up saying "GAME PAUSED" I can do this but it only stays up for like 1 sec and I want it to stay up till the users presses the escape key again
--in Keypressed
if key == 'escape' then
somevariable = not somevariable --toggles the variable between true and false
end
--in love.draw()
if somevariable == true then
love.graphics.print('THE GAME IS PAUSED', 10, 250, whatever
end
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
function love.load()
pause = false
end
function love.update(dt)
function love.keypressed(key, unicode)
if key == 'p' then pause = not pause end
end
end
function love.draw()
if pause then love.graphics.print("Game is paused",0,0) else
love.graphics.print("Game is running",0,0) end
end
I would strongly suggest against using an else like that, wrapping your entire function in an if statement because you want to pause seems highly invasive, it's better to just return from the if case.
bartbes wrote:I would strongly suggest against using an else like that, wrapping your entire function in an if statement because you want to pause seems highly invasive, it's better to just return from the if case.