2013-07-01 8 views
1

나는 corona sdk에서 프로그램의 흐름에 대해 매우 혼란스러워합니다.lua/corona sdk 코드의 흐름에 문제가 발생했습니다.

내가 원하는 것은 전환이 끝나면 플로우가 계속되고, 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 
    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}) 

이 완료되면 킵가 실행 만들고 싶어, 그래서 당신이 설명 할 수 있기를 바랍니다 그다지

답변

0

아마 당신이 할 수있는 이 속임수를 사용하지만 이것을 권장하지 않습니다. 런타임이 차단 될 수 있습니다. 나는 당신이 함수를 작성하는 것이 좋습니다.

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 
: 그래서 당신은 어쨌든 onComplete를 방법을 제대로

을 사용할 수 있습니다, 여기를 해결하기 위해 나쁜하지만 빠른 방법입니다

관련 문제