love.timer.sleep or wait()
Posted: Thu Aug 29, 2013 2:57 pm
Just wondering if I can do something like wait()
I tried love.timer.sleep, the game just crashed.
Tried googling it, I saw the wiki page.
I got this code that increases the variable every one second:
That crashes the game also and where did one second come from?
What it does is increase the number while you hold the up arrow, decrease the number while you hold the down arrow, and stop before it goes into the negatives.
What I need it to do is have some sort of sleep() so that it waits a certain amount of time before increasing the number again.
Sorry if this is kind of a dumb question in general, I'm new to love2d.
I tried love.timer.sleep, the game just crashed.
Tried googling it, I saw the wiki page.
I got this code that increases the variable every one second:
Code: Select all
x = 0
function love.update(dt)
x = x + dt
end
Code: Select all
function love.load()
logo = love.graphics.newImage("logo.png")
medium = love.graphics.newFont(45)
num = 0
end
function love.update(dt)
if love.keyboard.isDown("up") then
num = num + 1
end
if love.keyboard.isDown("down") and num > 0 then
num = num - 1
end
end
function love.draw()
love.graphics.print(num, 200, 200)
love.graphics.setFont(medium)
end
What I need it to do is have some sort of sleep() so that it waits a certain amount of time before increasing the number again.
Sorry if this is kind of a dumb question in general, I'm new to love2d.