为什么这段代码没有启动?
Why is this code not starting?
我正在尝试模拟 Simon Says 游戏。我目前正在使用 Corona SDK,并使用 Lua 作为我的语言。
我已将 addEventListener(touch)
放在函数 "starting" 上。我试过调试它,似乎代码没有正确 运行 说 if (started) then
语句的部分。如果你们能帮我指引正确的方向,我将不胜感激!
这是我的部分代码:
local function starting(event)
if (started == false) then
started = true
end
if (event.phase == "ended") then
start()
startText.isVisible = false
---------------------------------------------------
--THIS BELOW PART IS WRONG-- does not do "started"
if (started) then
count = count + 1
--if started--
if(math.mod(count,20) == 0) then
clicked = 0
if(light >= 0) then
light = light - 1
end
end
确保您已将 started 初始化为 false,就像上面提到的 rpattiso 一样。同样在我过去使用 Lua 的经验中,有时只是把 if (started) then
对我不起作用,所以你应该尝试 if (started == true) then
.
我正在尝试模拟 Simon Says 游戏。我目前正在使用 Corona SDK,并使用 Lua 作为我的语言。
我已将 addEventListener(touch)
放在函数 "starting" 上。我试过调试它,似乎代码没有正确 运行 说 if (started) then
语句的部分。如果你们能帮我指引正确的方向,我将不胜感激!
这是我的部分代码:
local function starting(event)
if (started == false) then
started = true
end
if (event.phase == "ended") then
start()
startText.isVisible = false
---------------------------------------------------
--THIS BELOW PART IS WRONG-- does not do "started"
if (started) then
count = count + 1
--if started--
if(math.mod(count,20) == 0) then
clicked = 0
if(light >= 0) then
light = light - 1
end
end
确保您已将 started 初始化为 false,就像上面提到的 rpattiso 一样。同样在我过去使用 Lua 的经验中,有时只是把 if (started) then
对我不起作用,所以你应该尝试 if (started == true) then
.