Copy link to clipboard
Copied
game limit is 1 min but if user will complete game within 20 sec then he will get 500 bonus points
how to code for this
//this is count up timer script
var intID;
var endTime = getTimer()+(59*1000);
makeTime();
function updateTimer() {
var t = endTime-getTimer();
if (t>0) {
makeTime();
showTime(t);
} else {
stopTimer();
showTime(0);
gotoAndStop("over");
trace("lost");
}
}
function makeTime() {
clearInterval(intID);
intID = setInterval(updateTimer, 100);
}
function stopTimer() {
clearInterval(intID);
}
function showTime(t) {
dispTime.text = (t/1000) >> 0;
}
Wherever in your code where the game is ended, you need to check the time value to see if it is <20 seconds and add the bonus to the score if it is.
Copy link to clipboard
Copied
Wherever in your code where the game is ended, you need to check the time value to see if it is <20 seconds and add the bonus to the score if it is.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now