2 sachinks SachinKS 于 2013.07.08 13:20 提问

corona sdk 移动对象问题

下面的代码在场景中移动对象。但是引起内存泄露,并且没有响应。

//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()

怎么样解决内存泄露的问题?

1个回答

loFataMer
loFataMer   2013.07.08 14:45
已采纳
//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

Csdn user default icon
上传中...
上传图片
插入图片