Is It A Bad Idea To Call Timer.pferofmwithdelay In A Loop?

Hi,

I’m having problem with this code:

 --Start making foods for i = 1, Waves[waveCounter][randomlyChosenWave].numOfFoods do timer.performWithDelay( i \* 1000, makeOneFoodObject ( Waves[waveCounter][randomlyChosenWave].speed ), 1) end

Basically I want to call makeOneFoodObject function in intervals with delay of 1second, then 2seconds which is achieved with i * 1000 part. Problem is, Corona calls makeOneFoodObject almost instantly and thus generates all foods at once!

What am I missing here?

Thanks!

My bad, I totally forgot that we have to use closures to pass parameters to timers. But it would be more convenient if we would not have to, I think it’s due to LUA’s structure.

My bad, I totally forgot that we have to use closures to pass parameters to timers. But it would be more convenient if we would not have to, I think it’s due to LUA’s structure.