Timer

Found a bug? Post information about it here so we can fix it!

Moderator: Moderators

Post Reply
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Timer

Post by y offs et »

Is this a bug?
Attachments
decError.zip
(84.21 KiB) Downloaded 469 times
"great expectations"
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I don't get it, is the timer not executing once per frame? Since the fps-interval setting isn't guaranteed to take exactly 1 second per frame (there will always be small deviations depending on Windows timer resolution), the timer will probably sometimes skip one frame and execute the next. If you want it to execute once per frame, try setting it to 0.95 or something like that.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:!:

You shouldn't use the Timer Component for precision critical behavior. Attached is a example of a frame-independent timer ( top ) versus the Timer Component ( bottom ) both running at a interval of 0.125. The framerate is automatically varied in the 10-30 range.

K
Attachments
Timer.zip
(30.29 KiB) Downloaded 484 times
Last edited by Kjell on Wed May 05, 2010 3:24 pm, edited 1 time in total.
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

OK, whatever. I just came across this while trying to fine tune my animation.
It doesn't matter how many frames per second - at timer 1 second interval, it updates once for every 10 position updates. Here it is running at 5 frames per second. It just looked like a misplaced decimal point somewhere.
Attachments
animSprite_3.zip
(53.86 KiB) Downloaded 479 times
"great expectations"
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:roll:

ZGameEditor's time delta has a limit of 0.1. This means that as soon as the framerate drops below 10 fps your application starts slowing down* So it's not a bug .. although it would be nice if the threshold was a property of App ( so you can increase it for debugging purposes like yours ).

*For example, your character itself doesn't move as fast as it does with any framerate above 10 either.

K
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

Well, I kinda understand.
The fix appears to be don't debug below 11 FPS.

EDIT - With this you can

timer.interval x 4
steeringController.maxSpeed / 4

or something like that

and get a close look to get the best possibility under these circumstances.
"great expectations"
Post Reply