Curious Millisecs thing

BlitzMax Forums/BlitzMax Programming/Curious Millisecs thing

Perturbatio(Posted 2005) [#1]
I've been messing around trying to create a timer that triggers at a specified interval and it appears to be working except that with the test code I am disabling the timer on left click and enabling on right click but it takes a good 2-3 seconds to re-enable unless I comment out the code that resets the FStartTime field to Millisecs()

EventTimer.bmx:


test code:

the image I'm using:



KamaShin(Posted 2005) [#2]
I ve read your post a bit fast so maybe I m missing something but I think the problem comes from this line:
in your UpdateTimer method you have:
FCurrentTime = MilliSecs() - FStartTime
when you resume you do FStartTime = Millisecs()
and thus when calling UpdateTimer, MilliSecs() - FStartTime is equal to 0
and your if statement (If FCurrentTime - FLastTickTime => FInterval Then) is false until you ve catched back the time the Timer has been alive...

(and just a small, very small remark, you can replace the following:
frame:+1
If frame > 9 Then frame = 0
by:
frame = (frame + 1) Mod 10
)