程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ios- corona sdk 移動對象問題

ios- corona sdk 移動對象問題

編輯:編程綜合問答
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()

怎麼樣解決內存洩露的問題?

最佳回答:


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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved