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??