Hi i am trying to make a count-up timer that starts at 0 and stops at 5mins. However the code will not stop and keeps going, im new at javascript(well programming in general) and i would appreciated it if anyone could give me a hand in making the time stop at the maxTime int. Thanks
var maxTime: int;
private var startTime: int = 0;
private var roundedRestSeconds : int;
private var displaySeconds : int;
private var displayMinutes : int;
private var countUpSeconds : int;
function Start()
{
startTime = Time.time;//timer
}
function OnGUI () {
//timer
var guiStart = Time.time + startTime;
restSeconds = countUpSeconds + (guiStart);
if (restSeconds == 240) {
print ("One Minute Left");
}
if (restSeconds == 300) {
print ("Time is Over");
var guiStop = Time.time - maxTime;
}
//display the timer
roundedRestSeconds = Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = roundedRestSeconds / 60;
text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds);
GUI.Label (Rect (200, 10, 100, 30),text);
//
}