0

Whenever I hit space bar I get this error: "Attempt to call field "resume" a nil value."
The intention is to the hit space bar once to stop the audio, and hit it again to resume.

if(key == "space") then
    love.audio.pause()
    paused = true
end
if paused == true then
    if (key == "space") then
        love.audio.resume()
    end 
end

Things I tried:
Changing "==" to "=" and vice versa;
Using "and" to avoid the nested "if" statement.

Documentation (if needed): http://love2d-community.github.io/love-api/#audio_resume

Any help is appreciated, and thank you for your time.

1 Answer 1

3
if key == "space" then
   if paused then
      love.audio.resume()
   else
      love.audio.pause()
   end
   paused = not paused
end

But love.audio.resume was removed in LÖVE 11.
Use love.audio.play instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.