Hey guys, I need a little help with this; when the sound (you can't hear it) ends, I want the counter to increase by 1 when the sound plays again, but most of the time it increases by 2, 3, and I can't see why..
function love.load()
oldcounter = 0
counter = 0
local samples = math.floor(1 * 44100) -- create sound; 1 second silence
local data = love.sound.newSoundData(samples, 44100, 16, 1)
for i = 0,samples do data:setSample(i, 0) end
silence = love.audio.newSource(data)
love.audio.play(silence)
end
function love.update(dt)
if silence:isStopped() then
love.audio.play(silence)
counter = counter + 1
end
end
function love.draw()
love.graphics.print(counter, 1, 100)
end
local one_second
local count
function love.load()
one_second = 0
count = 0
end
function love.update( dt )
one_second = one_second + dt
if one_second >= 1 then
one_second = one_second - 1
count = count + 1
end
end