FPS based counters


(Nazo Systems) #1

Hello! I would like to know if it’s possible to make a counter in FlashPunk or AS3 based on something else other than FPS. What I mean exactly is this, in our next game the player can charge the bullet before it releases it. The time that it takes for the charge to go from, let’s say, level 1 to level 2 is measured in FPSs. I am somewhat of a perfectionist, yes I know everyone hates those, but a counter based on FPS is just way too inexact for me and could cause a lot of problems on slower PCs, that being my main concern.

Is there a way to make a counter not based on FPS? Or does anyone know a more reliable way to make a counter?

Thank you for your time!


(Ultima2876) #2

There’s a variable called FP.elapsed that gets the time in milliseconds since the last frame. You can use is to time something to be once per second or once every 200ms or whatever.

Bear in mind that if the game is lagging on someone’s system, they will still only see maximum of fps updates per second, meaning even if you try to make the timer accurate to the millisecond, they won’t see it (or be able to interact in such a way that it would matter).

Also timers on computers in general are only ever accurate to 10ms. This is a limitation that is difficult to get around in Flash.


(Nazo Systems) #3

Thanks for the reply! I will keep what you said in mind.