我試圖對我的測驗實施分數。添加分數並顯示爲3
目前,它的工作原理是當用戶點擊正確答案(這是一個按鈕),它顯示的地方它說的答案是正確的,並顯示得分框架。
如果用戶得到的答案錯誤(又是一個按鈕),它會轉到框架,它表示答案是錯誤的,分數將保持不變。
我的代碼是針對測驗按鈕如下:
第一個正確答案:
//implementation of score
var score;
score = 0;
//adding points to score
score ++;
//setting the txt text field to score
scorecounter.text = score.toString();
//not embedding the font to display the score
scorecounter.embedFonts = false;
每一個相應的正確答案:
//adding to score
score ++;
//setting the txt text field to score
scorecounter.text = score.toString();
scorecounter.embedFonts = false;
中的對應不正確的答案:
//adding to score
score --;
//setting the txt text field to score
scorecounter.text = score.toString();
scorecounter.embedFonts = false;
我已經有靜態文本說分數,動態文本旁邊是空白的,稱爲scorecounter,我希望分數上升一個。
現在所發生的事情是,當用戶接聽第一個答案不正確(或不正確不夠),以顯示「南」。
測驗有五個問題,所以我希望數字變量下降,如果用戶得到錯誤的問題,但只讓它下降到零,並最多五個可能的最高分數(如果用戶得到所有正確的)。
我該怎麼做? 乾杯!
偉大的,謝謝!我能夠解決它。 現在我有一個錯誤,我只希望它在0-5之間顯示得分,現在如果第一個問題的答案是錯誤的,那麼它顯示NaN。能夠幫助嗎? – ConfusedDreamweaverUser
更新後的代碼供您上面查看,如果您可以幫助:) – ConfusedDreamweaverUser
也回答了這個問題。請記住檢查最佳效果答案旁邊的綠色勾號。當然,如果您想要更好的解答,您可以等待幾天。 –