How to make personalized counter/timer using dt?

Just started using Construct 2? Post your questions here

Post » Thu Mar 13, 2014 11:48 pm

So I am trying to make a cool down timer, and have set the variable customTimer to 0, and if customTimer >0, then add dt to customTimer every tick. As I understand it, if I do it this way, after every second, the value of customTimer should be pretty close to 1.0. However, sometimes, the timer is really slow and takes 1.5 seconds to reach 1.0. Why is it like this?
B
4
S
1
Posts: 18
Reputation: 388

Post » Fri Mar 14, 2014 2:07 am

dt*60 will result 1 every second
B
83
S
22
G
15
Posts: 1,039
Reputation: 15,219

Post » Fri Mar 14, 2014 9:10 am

If your frame rate is dropping below 10 fps then this will make your timer slow ?

Have you looked at the timer behaviour to do this delay ?
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Fri Mar 14, 2014 7:35 pm

@7Soul you're answer is so short that it looks wrong (:

@wp2000 for some (probably good) reasons I didn't have the motivation to investigate, c2 doesn't allow dt to be greater than 0.1s, if your game is slower than 10 fps, dt will then be wrong.
on 60 fps -> dt = 1/60 = 0.017 so after 60 frames of adding dt you get 1 (probably what 7Soul meant)
on 10 fps -> dt = 1/10 = 0.1 after 10 frames you get 1 as well
on 5 fps -> dt = 1/10 = 0.1 after 5 frames you only get 0.5 and that's probably your issue

The work around is to compute your own dt value using the wallclocktime system property.
I made a practical example few days ago: hiddenObjectClock.capx
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests