【发布时间】:2018-09-17 01:18:22
【问题描述】:
每当我点击空格键时,我都会收到此错误:“尝试调用字段“恢复”一个 nil 值。”
目的是按一次空格键停止音频,再按一次恢复。
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-statement lua love2d nested-if