1
我試圖將一個對象隨機移動到不同的位置,所以我拿出以下內容:transition.to隨機生成x,y以及時間,並在完成時運行另一個函數,檢查對象是否仍在那裏,並將其發送到不同的位置。如何用transition.to隨機移動一個對象?
,但我得到一個錯誤:
Runtime error
main.lua:352: stack overflow
stack traceback:
main.lua:352: in function
'toAnotherPlace'
看起來像電暈並沒有真正等待過渡完整,所以它的推移無限循環
代碼
function toAnotherPlace(object)
if object ~= nil then
transition.to(object,
{
time=math.random(1500,6000),
alpha=1,
x=(math.random(10, 310)),
y=(math.random(10, 400)),
onComplete=toAnotherPlace(object)
})
end
end
transition.to(bossess[boss],
{
time=math.random(1500,6000),
alpha=1,
x=(math.random(10, 310)),
y=(math.random(10, 400)),
onComplete=toAnotherPlace(bossess[boss])
})
是的參考,這是準確的話,謝謝! – Bnhjhvbq7