function powerup(e)
local rtran
reloj.x=math.random(10,300)
reloj.y=-70
rtran=transition.to(reloj,{time=math.random (130000,140000),y=9000}) -- removed the onComplete
end
-- timer.performWithDelay(delay in milliseconds between function calls,function to call,how many times to call the function?)
-- 1 sec = 1000 milliseconds
timer.performWithDelay(1000, powerup,5)
上面的代碼將調用通電功能每隔1秒5次。既然你想獲得一段時間後執行timer.performWithDelay代碼,而不是從應用開始的開始,把它放在函數中並調用該函數如下圖所示
local function launchAfterSomeTime()
timer.performWithDelay(1000, powerup,5)
end
-- here delay is the delay you want before
-- you call launchAfterSomeTime function
timer.performWithDelay(delay,launchAfterSomeTime,1)
不要忘了取消現場計時器退出,如果你正在使用storyBoard或作曲家API的
希望這可以解決你的問題,快樂的編碼!
你的問題是什麼? –
請澄清你的問題,你想「出現」什麼物體?該代碼不夠清晰,無法提供您想要實現的線索...... –
嗨。謝謝回答。 我希望它出現的對象是「reloj」;隨着transition.to它從事件開始以來隨機出現,但我希望它每隔「x」秒就會出現一次,例如:每十秒鐘一次,並且從一個特定的時間開始,而不是從一開始。 我認爲這可以用計時器完成,但我不知道如何。 感謝您的幫助 – user3474666