2013-06-22 35 views
1

我試圖創建一個簡單的遊戲,在定時器耗盡之前需要用戶的輸入。有沒有辦法在等待輸入時有倒數計時器?

基本上,頁面會加載一段時間,然後等待用戶說出正確的答案。如果時間用完,遊戲結束,但如果用戶正確的話,他就會轉向下一個問題。

(我已經得到了語音部分制定出來的,我只需要弄清楚定時器)

是否有一個簡單的方法來做到這一點?

+0

我看不出問題在哪裏。創建一個定時器和倒計時:D –

+0

我從來沒有做過任何Windows手機應用程序,我還是相當新的C#,所以我甚至不知道什麼谷歌。 – smarble

+0

請指定您的問題。你不知道如何顯示倒計時或如何倒計時或什麼:)? –

回答

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() 

這是否解決了您的問題?

相關問題