Accurate Time

Get help using Construct 2

Post » Fri Jan 27, 2012 6:10 pm

I think I've got it now. Thanks for your help!
B
2
Posts: 5
Reputation: 260

Post » Fri Jan 27, 2012 6:15 pm

[QUOTE=Weishaupt] It think ticks are client dependent, ie a tick on a high speed four core processor might be shorter than on an old x86...

But maybe Ashley could answer this.[/QUOTE]
Yes, ticks vary depending on your system speed and browser speed. That's why you should use dt in your events, to account for that variance and provide a consistent gameplay
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Sat Jan 28, 2012 11:04 pm

Adding dt like that isn't actually perfectly accurate, it will accumulate small errors over time due to the nature of floating point addition.

Construct 2's runtime does its timing with higher precision to avoid that issue, so 'every 1 second' should actually be more accurate than adding 1 to dt every second. You should also just round the returned time because a game running at 60 fps only runs a tick every 16ms which means the time can be anything within 16ms of its intended time.

The problem with accuracy getting worse over time with 'Every X seconds' was actually a small bug - I've fixed it for the next build.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Previous

Return to How do I....?

Who is online

Users browsing this forum: tatogame and 27 guests