当我运行代码时,它告诉我在’=’附近有一个’)’错误: function restartLvl() for i = 1, #balloonTexts do display.remove(balloonTexts[i]) print ("restart level") end score.text = '0' ballRemain.text = '3' balloonText = {
function restartLvl()
for i = 1, #balloonTexts do
display.remove(balloonTexts[i])
print ("restart level")
end
score.text = '0'
ballRemain.text = '3'
balloonText = {}
createBalloons(1, 3)
if (askUser.isVisible = true) then --this is the line where the error occured
askUser.isVisible = false
end
if (yesBtn.isVisible = true) then
yesBtn.isVisible = false
end
if (noBtn.isVisible = true) then
noBtn.isVisible = false
end
end
我不知道它是如何仍然缺少’)’,因为我关闭了所有括号.
=是赋值运算符,==是测试相等的运算符.将其更改为:if (askUser.isVisible == true) then
askUser.isVisible = false
end
还有其他所有人.为简单起见,可以省略括号():
if askUser.isVisible == true then
askUser.isVisible = false
end
如果值是布尔值,您也可以这样做,因为所有非nil或false的值都被视为true.
if askUser.isVisible then
askUser.isVisible = false
end
