Add: load literature file
Fix: text align to left
This commit is contained in:
@@ -60,10 +60,11 @@ var TypingExamination = {
|
|||||||
this.animalList = new AnimalList(670);
|
this.animalList = new AnimalList(670);
|
||||||
|
|
||||||
|
|
||||||
var TYPING_CONTENT_X = 100;
|
var TYPING_CONTENT_X = 60;
|
||||||
var TYPING_CONTENT_Y = 340;
|
var TYPING_CONTENT_Y = 340;
|
||||||
|
|
||||||
textStyleBasic.font = "bold 52px Arial";
|
textStyleBasic.font = "bold 52px Arial";
|
||||||
|
// textStyleBasic.backgroundColor = 'rgba(0,255,0,0.25)';
|
||||||
|
|
||||||
this.textTypingContent = game.add.text(
|
this.textTypingContent = game.add.text(
|
||||||
TYPING_CONTENT_X, TYPING_CONTENT_Y,
|
TYPING_CONTENT_X, TYPING_CONTENT_Y,
|
||||||
@@ -72,11 +73,13 @@ var TypingExamination = {
|
|||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||||
.addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
|
.addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
|
||||||
this.textTypingContent.anchor.set(0, 0.5);
|
this.textTypingContent.anchor.set(0, 0.5);
|
||||||
|
console.log(this.textTypingContent);
|
||||||
|
|
||||||
var TYPING_OFFSET_Y = 100;
|
var TYPING_OFFSET_Y = 100;
|
||||||
var TYPING_PREVIEW_OFFSET_Y = 40;
|
var TYPING_PREVIEW_OFFSET_Y = 40;
|
||||||
var TYPING_TEXT_OFFSET_HEIGHT = 70;
|
var TYPING_TEXT_OFFSET_HEIGHT = 50;
|
||||||
textStyleBasic.font = "52px Arial";
|
textStyleBasic.font = "38px Arial";
|
||||||
|
textStyleBasic.backgroundColor = null;
|
||||||
|
|
||||||
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||||
this.textTypingContentsDone = [];
|
this.textTypingContentsDone = [];
|
||||||
@@ -90,7 +93,7 @@ var TypingExamination = {
|
|||||||
.addColor(textDoneColor[i], 0);
|
.addColor(textDoneColor[i], 0);
|
||||||
this.textTypingContentsDone[i].anchor.set(0, 0.5);
|
this.textTypingContentsDone[i].anchor.set(0, 0.5);
|
||||||
|
|
||||||
var SCORE_POSITION_X = 900;
|
var SCORE_POSITION_X = 860;
|
||||||
|
|
||||||
this.textTypingRecordsDone[i] = game.add.text(
|
this.textTypingRecordsDone[i] = game.add.text(
|
||||||
SCORE_POSITION_X, TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
|
SCORE_POSITION_X, TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
|
||||||
@@ -120,8 +123,8 @@ var TypingExamination = {
|
|||||||
this.inputTextContent.anchor.set(0, 0.5);
|
this.inputTextContent.anchor.set(0, 0.5);
|
||||||
this.inputTextContent.canvasInput.value('');
|
this.inputTextContent.canvasInput.value('');
|
||||||
this.inputTextContent.canvasInput.focus();
|
this.inputTextContent.canvasInput.focus();
|
||||||
this.inputTextContent.canvasInput.fontSize(52);
|
this.inputTextContent.canvasInput.fontSize(38);
|
||||||
this.inputTextContent.canvasInput.placeHolder("입력 후 Space, Enter키를 누르세요");
|
this.inputTextContent.canvasInput.placeHolder("");
|
||||||
// inputTextContent.canvasInput._onkeydown = this.checkInputText;
|
// inputTextContent.canvasInput._onkeydown = this.checkInputText;
|
||||||
// inputTextContent.canvasInput._onkeyup = function() {
|
// inputTextContent.canvasInput._onkeyup = function() {
|
||||||
this.inputTextContent.canvasInput._onkeyup = function() {
|
this.inputTextContent.canvasInput._onkeyup = function() {
|
||||||
@@ -160,7 +163,7 @@ var TypingExamination = {
|
|||||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||||
|
|
||||||
|
|
||||||
this.startGame();
|
this.loadExaminationContent();
|
||||||
// this.countDown();
|
// this.countDown();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -246,20 +249,6 @@ var TypingExamination = {
|
|||||||
|
|
||||||
|
|
||||||
initTypingData: function() {
|
initTypingData: function() {
|
||||||
var typingTextMan = new TypingTextManager();
|
|
||||||
|
|
||||||
var typingPracticeContents = this.getTypingExaminationContents();
|
|
||||||
// var typingPracticeContents = [ "십년이면 강산도 변한다." , "십년이면 강산도 변한다.", "십년이면 강산도 변한다." ]; // for debug
|
|
||||||
// var typingPracticeContents = [ "꿰뚫다" , "워머신", "홧김에" ]; // for debug
|
|
||||||
console.log(typingPracticeContents);
|
|
||||||
typingTextMan.makeExaminationContents(typingPracticeContents);
|
|
||||||
// var wordCountForStage = TypingExamination.WORD_COUNT_FOR_STAGE;
|
|
||||||
// if(isDebugMode())
|
|
||||||
// wordCountForStage = 3;
|
|
||||||
// typingTextMan.slice(0, wordCountForStage);
|
|
||||||
this.typingRandomContents = typingTextMan.getContents();
|
|
||||||
// console.log(this.typingRandomContents);
|
|
||||||
this.typingContentLength = this.typingRandomContents.length;
|
|
||||||
this.typingIndex = 0;
|
this.typingIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -273,39 +262,43 @@ var TypingExamination = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
getTypingExaminationContents: function() {
|
loadExaminationContent: function() {
|
||||||
var TypingExaminationContents = this.loadTestContent();
|
game.load.onLoadComplete.add(this.literatureLoadComplete, this);
|
||||||
|
|
||||||
|
game.load.text("literature", "./../../game/typing/literature_list/korean_national_anthem.txt");
|
||||||
|
game.load.start();
|
||||||
|
},
|
||||||
|
|
||||||
|
literatureLoadComplete: function() {
|
||||||
|
game.load.onFileComplete.remove(this.loadExaminationContent, this);
|
||||||
|
game.load.onLoadComplete.remove(this.literatureLoadComplete, this);
|
||||||
|
|
||||||
|
var literature = game.cache.getText("literature");
|
||||||
|
var examinationContent = literature.split("\n");
|
||||||
|
|
||||||
|
for(var i = 0; i < examinationContent.length; i++) {
|
||||||
|
examinationContent[i] = examinationContent[i].replace(/\r/g, "");
|
||||||
|
// examinationContent[i] = examinationContent[i].replace(/ /g, TypingExamination.SPACE_INDICATOR);
|
||||||
|
}
|
||||||
|
|
||||||
// console.log('playingStageData.language : ' + playingStageData.language);
|
// console.log('playingStageData.language : ' + playingStageData.language);
|
||||||
// console.log('playingStageData.level : ' + playingStageData.level);
|
// console.log('playingStageData.level : ' + playingStageData.level);
|
||||||
// console.log('TypingExaminationContents : ' + TypingExaminationContents);
|
// console.log('examinationContent : ' + examinationContent);
|
||||||
|
|
||||||
this.typingRecordForLines = [];
|
this.typingRecordForLines = [];
|
||||||
this.typingElapsedTime = [];
|
this.typingElapsedTime = [];
|
||||||
for(var i = 0; i < TypingExaminationContents.length; i++) {
|
for(var i = 0; i < examinationContent.length; i++) {
|
||||||
this.typingRecordForLines[i] = 0;
|
this.typingRecordForLines[i] = 0;
|
||||||
this.typingElapsedTime[i] = 0;
|
this.typingElapsedTime[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TypingExaminationContents;
|
var typingTextMan = new TypingTextManager();
|
||||||
},
|
typingTextMan.makeExaminationContents(examinationContent);
|
||||||
|
this.typingExaminationContents = typingTextMan.getContents();
|
||||||
|
// console.log(this.typingExaminationContents);
|
||||||
|
this.typingContentLength = this.typingExaminationContents.length;
|
||||||
|
|
||||||
loadTestContent: function() {
|
this.startGame();
|
||||||
// game.load.text("literature", "./../literature_list/korean_national_anthem.txt");
|
|
||||||
|
|
||||||
var literature = game.cache.getText("literature");
|
|
||||||
var testContent = literature.split("\n");
|
|
||||||
|
|
||||||
for(var i = 0; i < testContent.length; i++) {
|
|
||||||
testContent[i] = testContent[i].replace(/\r/g, "");
|
|
||||||
console.log("typingContent : [" + testContent[i] + "], length : " + testContent[i].length);
|
|
||||||
testContent[i] = testContent[i].replace("\n", "");
|
|
||||||
// var char = testContent[i];
|
|
||||||
// for(var j = 0; j < char.length; j++) {
|
|
||||||
// console.log("[" + j + "] : " + char[j].charCodeAt(0).toString(16));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
return testContent;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showTypingExaminationContents: function() {
|
showTypingExaminationContents: function() {
|
||||||
@@ -315,7 +308,7 @@ var TypingExamination = {
|
|||||||
this.textTypingContentsDone[i].text = "";
|
this.textTypingContentsDone[i].text = "";
|
||||||
this.textTypingRecordsDone[i].text = "";
|
this.textTypingRecordsDone[i].text = "";
|
||||||
} else {
|
} else {
|
||||||
this.textTypingContentsDone[i].text = this.typingRandomContents[doneIndex];
|
this.textTypingContentsDone[i].text = this.typingExaminationContents[doneIndex];
|
||||||
this.textTypingRecordsDone[i].text = Math.floor(this.typingRecordForLines[doneIndex]);
|
this.textTypingRecordsDone[i].text = Math.floor(this.typingRecordForLines[doneIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,12 +318,12 @@ var TypingExamination = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.textTypingContent.text = this.typingRandomContents[this.typingIndex];
|
this.textTypingContent.text = this.typingExaminationContents[this.typingIndex];
|
||||||
|
|
||||||
for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||||
var previewIndex = this.typingIndex + i + 1;
|
var previewIndex = this.typingIndex + i + 1;
|
||||||
if(previewIndex < this.typingRandomContents.length)
|
if(previewIndex < this.typingExaminationContents.length)
|
||||||
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
|
this.textTypingContentPreview[i].text = this.typingExaminationContents[previewIndex];
|
||||||
else
|
else
|
||||||
this.textTypingContentPreview[i].text = "";
|
this.textTypingContentPreview[i].text = "";
|
||||||
}
|
}
|
||||||
@@ -346,22 +339,24 @@ var TypingExamination = {
|
|||||||
if(this.isGameOver)
|
if(this.isGameOver)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var inputContent = this.inputTextContent.canvasInput.value().trim();
|
var inputText = this.inputTextContent.canvasInput.value().trim();
|
||||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
// var inputContent = inputText.replace(/ /g, TypingExamination.SPACE_INDICATOR);
|
||||||
|
var inputContent = inputText;
|
||||||
|
var typingContent = this.typingExaminationContents[this.typingIndex].trim();
|
||||||
|
|
||||||
if(event.keyCode == Phaser.Keyboard.ENTER ||
|
if(event.keyCode == Phaser.Keyboard.ENTER ||
|
||||||
event.keyCode == Phaser.Keyboard.SPACEBAR) {
|
event.keyCode == Phaser.Keyboard.SPACEBAR) {
|
||||||
console.log("### enter ###");
|
// console.log("### enter ###");
|
||||||
console.log("this.typingIndex : " + this.typingIndex);
|
// console.log("this.typingIndex : " + this.typingIndex);
|
||||||
console.log("inputContent : [" + inputContent + "], length : " + inputContent.length);
|
// console.log("inputContent : [" + inputContent + "], length : " + inputContent.length);
|
||||||
console.log("typingContent : [" + typingContent + "], length : " + typingContent.length);
|
// console.log("typingContent : [" + typingContent + "], length : " + typingContent.length);
|
||||||
|
|
||||||
if(inputContent === typingContent) {
|
if(inputContent === typingContent) {
|
||||||
console.log("input completed");
|
// console.log("input completed");
|
||||||
this.calculateTypingRecord(typingContent);
|
this.calculateTypingRecord(typingContent);
|
||||||
|
|
||||||
console.log("this.typingIndex : " + this.typingIndex);
|
// console.log("this.typingIndex : " + this.typingIndex);
|
||||||
console.log("this.typingContentLength : " + this.typingContentLength);
|
// console.log("this.typingContentLength : " + this.typingContentLength);
|
||||||
if(this.typingIndex == this.typingContentLength - 1) {
|
if(this.typingIndex == this.typingContentLength - 1) {
|
||||||
this.isGameOver = true;
|
this.isGameOver = true;
|
||||||
this.gameOver();
|
this.gameOver();
|
||||||
@@ -404,7 +399,7 @@ var TypingExamination = {
|
|||||||
/*
|
/*
|
||||||
updateKeyboard: function() {
|
updateKeyboard: function() {
|
||||||
var inputContent = this.inputTextContent.canvasInput.value();
|
var inputContent = this.inputTextContent.canvasInput.value();
|
||||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
var typingContent = this.typingExaminationContents[this.typingIndex];
|
||||||
|
|
||||||
this.hideHighlightKey(this.highlightKey);
|
this.hideHighlightKey(this.highlightKey);
|
||||||
this.highlightKey = this.getHighlioghtKey(inputContent, typingContent);
|
this.highlightKey = this.getHighlioghtKey(inputContent, typingContent);
|
||||||
@@ -686,7 +681,7 @@ var TypingExamination = {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
hideHighlightKey: function(highlightKey) {
|
hideHighlightKey: function(highlightKey) {
|
||||||
// var prevText = this.typingRandomContents[this.typingIndex];
|
// var prevText = this.typingExaminationContents[this.typingIndex];
|
||||||
if(highlightKey === undefined)
|
if(highlightKey === undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -694,7 +689,7 @@ var TypingExamination = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
showHighlightKey: function(highlightKey) {
|
showHighlightKey: function(highlightKey) {
|
||||||
// var typingText = this.typingRandomContents[this.typingIndex];
|
// var typingText = this.typingExaminationContents[this.typingIndex];
|
||||||
if(highlightKey === undefined)
|
if(highlightKey === undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -702,7 +697,7 @@ var TypingExamination = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
moveHands: function(highlightKey) {
|
moveHands: function(highlightKey) {
|
||||||
// var typingText = this.typingRandomContents[this.typingIndex];
|
// var typingText = this.typingExaminationContents[this.typingIndex];
|
||||||
if(highlightKey === undefined)
|
if(highlightKey === undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -733,7 +728,7 @@ var TypingExamination = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
calculateTypingRecord: function(typingContent) {
|
calculateTypingRecord: function(typingContent) {
|
||||||
// console.log('입력 단어 : ' + this.typingRandomContents[this.typingIndex]);
|
// console.log('입력 단어 : ' + this.typingExaminationContents[this.typingIndex]);
|
||||||
|
|
||||||
this.isTyping = false;
|
this.isTyping = false;
|
||||||
this.timeTypingEnd = game.time.elapsedSince(0);
|
this.timeTypingEnd = game.time.elapsedSince(0);
|
||||||
@@ -809,6 +804,8 @@ var TypingExamination = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TypingExamination.SPACE_INDICATOR = " · ";
|
||||||
|
|
||||||
TypingExamination.TYPING_CONTENT_PREVIEW_COUNT = 3; // 3;
|
TypingExamination.TYPING_CONTENT_PREVIEW_COUNT = 3; // 3;
|
||||||
TypingExamination.TYPING_CONTENT_DONE_COUNT = 3; // 3;
|
TypingExamination.TYPING_CONTENT_DONE_COUNT = 3; // 3;
|
||||||
TypingExamination.TYPING_COUNT_PLUS_ENTER = 1;
|
TypingExamination.TYPING_COUNT_PLUS_ENTER = 1;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ var Loading = {
|
|||||||
|
|
||||||
// Hand.loadResources();
|
// Hand.loadResources();
|
||||||
Animal.loadResources();
|
Animal.loadResources();
|
||||||
game.load.text("literature", "./../../game/typing/literature_list/korean_national_anthem.txt");
|
// game.load.text("literature", "./../../game/typing/literature_list/korean_national_anthem.txt");
|
||||||
|
|
||||||
|
|
||||||
// game.load.image('a', '../../../resources/image/icon/fullscreen_white.png');
|
// game.load.image('a', '../../../resources/image/icon/fullscreen_white.png');
|
||||||
@@ -78,6 +78,8 @@ var Loading = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
loadComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||||
|
game.load.onFileComplete.remove(this.fileComplete, this);
|
||||||
|
game.load.onLoadComplete.remove(this.loadComplete, this);
|
||||||
// this.preloadBar.alpha = 1;
|
// this.preloadBar.alpha = 1;
|
||||||
|
|
||||||
if(isDebugMode()) {
|
if(isDebugMode()) {
|
||||||
@@ -90,4 +92,7 @@ var Loading = {
|
|||||||
// this.startTypingTestStage();
|
// this.startTypingTestStage();
|
||||||
// this.startTypingTestResult();
|
// this.startTypingTestResult();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
nullFunction: function() {
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user