I have a cooldown timer which I made by creating a small slice and displaying it 360 times to make a circle.
To show the cooldown is being reset, I remove a slice of the circle.
It works fine, except that the time I am expecting it to take to run the code to remove one slice is taking longer than expected, and is not consistent...
Here is my block of code to remove the slice:
local the_time = system.getTimer() local slice_counter = 1 local function removeSlice() print("time since last ran: " .. (system.getTimer() - the_time)) the_time = system.getTimer() display.remove(cd_slices[slice_counter]) cd_slice[slice_counter] = nil if(slice_counter == 360) then cdOver() end slice_counter = slice_counter + 1 end print("cd_length: " .. cd_length) cd_timer = timer.performWithDelay(cd_length, removeSlice, 360)
I would expect the time taken between each time it removes a slice to be the same, and to be equal to cd_length.
But it is not....
cd_length is 5.6, but
time since last ran is all over the place, ranging from 9 to 21 instead of 5.6.
Am I doing something wrong or misunderstanding how timer.performWithDelay works??