下面的代碼在場景中移動對象。但是引起內存洩露,並且沒有響應。
//transition back
local function goBack( )
transition.to ( wall2, { time = 10000, x = 100, y = 310, onComplete = startTransition})
transition.to ( wall, { time = 10000, x = 700, y = 200, onComplete = startTransition})
transition.to (gate_a, { time = 10000, x = 100, y = 255, onComplete = startTransition})
transition.to ( stargate_a, { time = 10000, x = 100, y = 255, onComplete = startTransition})
end
//transition start
function startTransition( )
transition.to ( wall2, { time = 10000, x = 700, y = 310, onComplete = goBack})
transition.to ( wall, { time = 10000, x = 100, y = 200, onComplete = goBack})
transition.to ( gate_a, { time = 10000, x = 700, y = 255, onComplete = goBack})
transition.to ( stargate_a, { time =10000, x = 700, y = 255, onComplete = goBack})
end
startTransition()
怎麼樣解決內存洩露的問題?
//transition back
local function goBack( )
transition.to ( wall2, { time = 10000, x = 100, y = 310})
transition.to ( wall, { time = 10000, x = 700, y = 200})
transition.to (gate_a, { time = 10000, x = 100, y = 255})
transition.to ( stargate_a, { time = 10000, x = 100, y = 255, onComplete = startTransition})
end
//transition start
function startTransition( )
transition.to ( wall2, { time = 10000, x = 700, y = 310})
transition.to ( wall, { time = 10000, x = 100, y = 200})
transition.to ( gate_a, { time = 10000, x = 700, y = 255})
transition.to ( stargate_a, { time =10000, x = 700, y = 255, onComplete = goBack})
end
startTransition()
由於所有時間段都一樣長,所以不需要全部轉變都調用onComlpete