Delay function isn't working.
Posted: Sun May 27, 2012 4:17 am
Basically what the function is suppose to do is wait the amount of seconds specified. The function is inside the love.update function. This is the first block of code. The second block of code basically plays 2 noises if you click the left mouse button. First it plays the 'fire' noise, then after 5 seconds it's suppose to play the 'shell' noise. However, no time is waited at all and they're both played at the same time.
Code: Select all
function love.update(dt)
function wait(time)
local total = 0
repeat total = total + dt
until total >= time
end
end
function love.mousepressed(mousex, mousey, button)
if button == "l" then
fire = love.audio.newSource("src/sound/pistolfire.mp3", "static")
love.audio.play(fire)
wait(5)
--Shell dropping sound--
shell = love.audio.newSource("src/sound/pistolshell.mp3", "static")
love.audio.play(shell)
end
end