Skip to main content
Known Participant
March 3, 2013
Answered

complete game within 20 sec

  • March 3, 2013
  • 1 reply
  • 456 views

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;

}

This topic has been closed for replies.
Correct answer Ned Murphy

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.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
March 3, 2013

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.