Page 1 of 1

frame-based timers

PostPosted: Fri May 08, 2009 5:16 pm
by j2graves
it's often difficult to work with real-time timers, because sometimes the game lags and so things work slower, but the timers stay exactly the same, causing things to happen at the wrong time. having a frame-based timer would fix this up easily :)

Re: frame-based timers

PostPosted: Fri May 08, 2009 7:40 pm
by asmodeus
That is a really good thing! I propably would also need it! I could do it with a variable increasing / decreasing in each frame, but a built in frame timer would really help! :D

Re: frame-based timers

PostPosted: Sat May 09, 2009 4:42 am
by Fuzzy
You can make one. Make a global integer called frameNumber. In the create actor event for view, set it to zero. In draw actor event for view, add one to it.

Now say you want an actor to do something every 12 frames. Give the actor a variable of type int and set it to 12. Maybe the timer is called blinkRed. In draw actor, say

Code: Select all
if ((frameNumber % blinkRed) == 0)
{
    do stuff
}

Re: frame-based timers

PostPosted: Mon May 18, 2009 7:15 pm
by Hblade
If you want, I could make a script that will use frame based timers.