Lua 中嵌套 "IF" 条件的问题 (Love2D)
Problems with nested "IF" condition in Lua (Love2D)
每当我点击 space 栏时,我都会收到此错误:"Attempt to call field "resume" a nil value."
目的是按一次 space 条停止音频,再按一次恢复。
if(key == "space") then
love.audio.pause()
paused = true
end
if paused == true then
if (key == "space") then
love.audio.resume()
end
end
我尝试过的事情:
将“==”更改为“=”,反之亦然;
使用 "and" 避免嵌套的 "if" 语句。
文档(如果需要):http://love2d-community.github.io/love-api/#audio_resume
感谢您的帮助,感谢您抽出宝贵时间。
if key == "space" then
if paused then
love.audio.resume()
else
love.audio.pause()
end
paused = not paused
end
但是 love.audio.resume
was removed 在 LÖVE 11.
请改用 love.audio.play
。
每当我点击 space 栏时,我都会收到此错误:"Attempt to call field "resume" a nil value."
目的是按一次 space 条停止音频,再按一次恢复。
if(key == "space") then
love.audio.pause()
paused = true
end
if paused == true then
if (key == "space") then
love.audio.resume()
end
end
我尝试过的事情:
将“==”更改为“=”,反之亦然;
使用 "and" 避免嵌套的 "if" 语句。
文档(如果需要):http://love2d-community.github.io/love-api/#audio_resume
感谢您的帮助,感谢您抽出宝贵时间。
if key == "space" then
if paused then
love.audio.resume()
else
love.audio.pause()
end
paused = not paused
end
但是 love.audio.resume
was removed 在 LÖVE 11.
请改用 love.audio.play
。