lua/corona sdk代码中的流量故障
我对corona sdk中的程序流感到非常困惑 我想做的是,当转换结束时,流程将继续,我知道我可以使用Oncomplete,但我不知道在这种情况下如何使用它 我有以下代码:lua/corona sdk代码中的流量故障,lua,coronasdk,corona-storyboard,Lua,Coronasdk,Corona Storyboard,我对corona sdk中的程序流感到非常困惑 我想做的是,当转换结束时,流程将继续,我知道我可以使用Oncomplete,但我不知道在这种情况下如何使用它 我有以下代码: while ban == 2 do actual = x desplazar = x while actual >= 0 do actual = actual - 4 if inTable(t,actual) then while
while ban == 2 do
actual = x
desplazar = x
while actual >= 0 do
actual = actual - 4
if inTable(t,actual) then
while inTable(t,actual) and actual >=0 do
actual= actual - 4
end
end
if actual >= 0 then
banaux=1
if inTable(t, desplazar) then
block[desplazar].value=0
block[desplazar]:removeSelf()
for z=1, tablelength(t) do
if t[z] == desplazar then
t[z]=32
end
end
end
transition.to(block[actual], {time=velocity, x=block[desplazar].x, y=block[desplazar].y})
cambiodesp(actual,desplazar)
desplazar = desplazar - 4
end
end
x = x -1
if inTable(t,x) then
else
ban = 1
end
end
由于转换,我得到了很多意想不到的结果,我认为虽然转换尚未完成,但代码仍在运行,我想在转换完成后运行上面的代码,但我认为我不能使用oncomplete
我想在完成后继续跑步
transition.to(block[actual], {time=velocity, x=block[desplazar].x, y=block[desplazar].y})
我不了解代码流是如何工作的,所以希望您能向我解释一下,也许您可以使用这个技巧,但我不推荐这样做。因为它可能会阻塞运行时。我建议你写函数。所以您可以正确地使用onComplete方法 无论如何,这里有一个坏的但快速的方法来解决它:
while ban == 2 do
actual = x
desplazar = x
while actual >= 0 do
actual = actual - 4
if inTable(t,actual) then
while inTable(t,actual) and actual >=0 do
actual= actual - 4
end
end
if actual >= 0 then
banaux=1
if inTable(t, desplazar) then
block[desplazar].value=0
block[desplazar]:removeSelf()
for z=1, tablelength(t) do
if t[z] == desplazar then
t[z]=32
end
end
end
local isEnded = false
transition.to(block[actual], {time=velocity, x=block[desplazar].x, y=block[desplazar].y, onComplete = function() isEnded = true end })
while isEnded == false then end
cambiodesp(actual,desplazar)
desplazar = desplazar - 4
end
end
x = x -1
if inTable(t,x) then
else
ban = 1
end
end