Add: show result after typing test
This commit is contained in:
@@ -9,7 +9,7 @@ class Test {
|
||||
this.initTypingData();
|
||||
sessionStorageManager.isNewBestRecrd = false;
|
||||
|
||||
this.game.stage.backgroundColor = '#4d4d4d';
|
||||
game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
// top
|
||||
let backButton = new BackButton( () => {
|
||||
@@ -20,12 +20,7 @@ class Test {
|
||||
this.averageTypingSpeedText = new AverageTypingSpeed();
|
||||
this.contentProgressText = new ContentProgress();
|
||||
|
||||
// var scoreboardAreaPositionY = 2;
|
||||
// this.textPlayingWordNumber = game.add.text(900, scoreboardAreaPositionY, "0", textStyleBasic)
|
||||
// .setTextBounds(0, 0, 300, 80)
|
||||
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
let fullscreenButton = new FullscreenButton(this.game);
|
||||
let fullscreenButton = new FullscreenButton(game);
|
||||
|
||||
|
||||
// typing content
|
||||
@@ -77,7 +72,7 @@ class Test {
|
||||
|
||||
|
||||
// input text
|
||||
this.inputTextContent = new InputTypeText(this.game.world.centerX, typingAreaPositionY + 360);
|
||||
this.inputTextContent = new InputTypeText(game.world.centerX, typingAreaPositionY + 360);
|
||||
this.inputTextContent.anchor.set(0.5);
|
||||
this.inputTextContent.canvasInput.value('');
|
||||
this.inputTextContent.canvasInput.focus();
|
||||
@@ -132,7 +127,7 @@ class Test {
|
||||
*/
|
||||
|
||||
startGame() {
|
||||
this.initStage();
|
||||
this.averageTypingSpeedText.print(0);
|
||||
|
||||
this.showTypingTestContents();
|
||||
this.showPlayingWordNumber();
|
||||
@@ -145,6 +140,10 @@ class Test {
|
||||
}
|
||||
|
||||
goResult() {
|
||||
sessionStorageManager.record = this.typingRecordTotal;
|
||||
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
|
||||
sessionStorageManager.bestRecord = sessionStorageManager.record;
|
||||
|
||||
location.href = '../../web/client/result.html';
|
||||
}
|
||||
|
||||
@@ -163,12 +162,9 @@ class Test {
|
||||
this.timeTypingEnd = 0;
|
||||
|
||||
this.typingLetterCountTotal = 0;
|
||||
this.typingRecordTotal = 0;
|
||||
}
|
||||
|
||||
initStage() {
|
||||
// this.textBestRecord.text = Math.floor(sessionStorageManager.bestRecord);
|
||||
this.averageTypingSpeedText.print(0);
|
||||
}
|
||||
|
||||
getTypingTestContents() {
|
||||
var typingTestContents = this.loadTestContent();
|
||||
@@ -255,7 +251,8 @@ class Test {
|
||||
this.playNextContent();
|
||||
|
||||
if(this.typingIndex == this.wordCountForStage)
|
||||
this.state.start('TypingTestResult');
|
||||
this.goResult();
|
||||
// this.state.start('TypingTestResult');
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -295,7 +292,7 @@ class Test {
|
||||
// console.log('입력 단어 : ' + this.typingRandomContents[this.typingIndex]);
|
||||
|
||||
this.isTyping = false;
|
||||
this.timeTypingEnd = this.game.time.elapsedSince(0);
|
||||
this.timeTypingEnd = game.time.elapsedSince(0);
|
||||
// console.log('this.timeTypingEnd : ' + this.timeTypingEnd);
|
||||
|
||||
var elapsedTimeMS = this.timeTypingEnd - this.timeTypingStart;
|
||||
@@ -317,12 +314,13 @@ class Test {
|
||||
// console.log('i : ' + i + ' - time : ' + this.typingElapsedTime[i]);
|
||||
typingElapsedTimeTotal += this.typingElapsedTime[i];
|
||||
}
|
||||
let typingRecordTotal = this.typingLetterCountTotal * 60000 / typingElapsedTimeTotal;
|
||||
console.log(this.typingLetterCountTotal);
|
||||
console.log(typingElapsedTimeTotal);
|
||||
console.log(typingRecordTotal);
|
||||
this.typingRecordTotal = this.typingLetterCountTotal * 60000 / typingElapsedTimeTotal;
|
||||
// console.log(this.typingLetterCountTotal);
|
||||
// console.log(typingElapsedTimeTotal);
|
||||
// console.log(typingRecordTotal);
|
||||
|
||||
// this.textTypingRecordTotal.text = Math.floor(typingRecordTotal);
|
||||
this.averageTypingSpeedText.print(Math.floor(typingRecordTotal));
|
||||
this.averageTypingSpeedText.print(Math.floor(this.typingRecordTotal));
|
||||
// console.log('-------------- total --------------');
|
||||
// console.log('typingLetterCountTotal : ' + this.typingLetterCountTotal);
|
||||
// console.log('typingElapsedTimeTotal : ' + typingElapsedTimeTotal);
|
||||
@@ -338,12 +336,11 @@ class Test {
|
||||
}
|
||||
|
||||
showPlayingWordNumber() {
|
||||
// this.textPlayingWordNumber.text = (this.typingIndex + 1) + " / " + this.wordCountForStage;
|
||||
this.contentProgressText.print(this.typingIndex + 1, this.wordCountForStage);
|
||||
}
|
||||
|
||||
setTimeTypingStart() {
|
||||
this.timeTypingStart = this.game.time.elapsedSince(0);
|
||||
this.timeTypingStart = game.time.elapsedSince(0);
|
||||
var timeGap = this.timeTypingStart - this.timeTypingEnd;
|
||||
|
||||
if(timeGap < 50)
|
||||
|
||||
Reference in New Issue
Block a user