- Home /
Question by
Gusic · Feb 21, 2014 at 09:51 PM ·
2djavascriptbeginner
How do i slow down my counter? (JavaScript)
Hi Guys,
I have written out a timer script for my gui but it goes to fast and i don't know how to slow it down.
Thank You,
var Counter : int = 0;
function Update() {
Counter++;
guiText.text = ""+Counter;
}
Comment
How quickly should the timer increase, and what sorts of values were you hoping to display? At 1.5 seconds, should it show "1" or "1.5"?
Answer by Tropicana · Feb 27, 2014 at 10:50 AM
Your problem is that you are updating the timer on every frame. Try using a timer to make a method that updates the counter fire every X milliseconds/seconds etc. Also if you test your game in a powerfull rig, you most likely have more than 30 fps so it will be very fast.