Timer with random seconds ¿How to update the random seconds?
- by benLIVE
I have a timer "tmr_sendCesta" which must be called each x seconds between 1 and 3 seconds. The problem is the timer "tmr_sendCesta" is called only one time, and the random seconds is never updated. I need to call the function "createCesta" each x seconds randomly.
Any idea how to do it?
function createCesta()
cesta = display.newImageRect("cesta.png", 100, 55)
cesta.x = -110
cesta.y = screenH - 110
cesta.name = "cesta"
physics.addBody( cesta, physicsData:get("cestaSmall"))
grupoCesta:insert(cesta)
transition.to(cesta, {time = 4000, x = screenW + 110})
end
function scene:enterScene( event )
local group = self.view
physics.start()
Runtime:addEventListener("touch", touchScreen)
Runtime:addEventListener( "collision", onCollision )
tmr_sendCesta = timer.performWithDelay((math.random(1000, 3000), randomCesta, 0)
end