1

I'm trying to create a simple game that requires the user's input before the timer runs out.

Basically, the page will load with a time, and wait for the user to say the correct answer. If the time runs out, the game is over, but if the user gets it right, he moves on to the next question.

(i've got the speech part worked out, I just need to figure out the timer)

Is there an easy way to accomplish this?

smarble
  • 335
  • 4
  • 16

1 Answers1

1
//Add Using Statement
using System.Windows.Threading;

//Create Timer
DispatcherTimer mytimer;

//Setup Timer
myTimer = new DispatcherTimer();
myTimer.Interval = System.TimeSpan.FromSeconds(10);
myTimer.Tick += myTimer_Tick;

// When you type the +=, this method skeleton should come up
// automatically. But type this in if it doesn't.
void myTimer_Tick(object sender, EventArgs e)
{
    //This runs when ever the timer Goes Off (In this case every 10 sec)
}

//Run Timer
myTimer.Start()

//Stop Timer
myTimer.Stop()

Does this solve your question?

catfood
  • 4,267
  • 5
  • 29
  • 55
Mark Rover2341
  • 116
  • 1
  • 8