Add: TypingTextManager - makeExaminationContents

This commit is contained in:
2019-06-20 23:56:28 +09:00
parent a5a0f9f759
commit a3fb4a57cd
4 changed files with 129 additions and 19 deletions
+40 -18
View File
@@ -50,7 +50,7 @@ var TypingExamination = {
this.averageTypingSpeedText = new AverageTypingSpeed();
this.contentProgressText = new ContentProgress();
// this.contentProgressText = new ContentProgress();
// typing content
@@ -60,12 +60,17 @@ var TypingExamination = {
this.animalList = new AnimalList(670);
var TYPING_CONTENT_X = 60;
var TYPING_CONTENT_Y = 340;
var RECORD_POSITION_X = 900;
textStyleBasic.font = "bold 52px Arial";
// textStyleBasic.backgroundColor = 'rgba(0,255,0,0.25)';
textStyleBasic.font = "bold 38px Arial";
// textStyleBasic.backgroundColor = "rgba(0, 0, 0, 0.25)";
// current text
this.textTypingContent = game.add.text(
TYPING_CONTENT_X, TYPING_CONTENT_Y,
"", textStyleBasic
@@ -73,14 +78,26 @@ var TypingExamination = {
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
this.textTypingContent.anchor.set(0, 0.5);
console.log(this.textTypingContent);
var TYPING_OFFSET_Y = 100;
var TYPING_PREVIEW_OFFSET_Y = 40;
textStyleBasic.backgroundColor = null;
this.textTypingLine = game.add.text(
RECORD_POSITION_X, TYPING_CONTENT_Y,
"", textStyleBasic
)
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
// .addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
this.textTypingLine.anchor.set(0.5);
var TYPING_OFFSET_Y = 70;
var TYPING_PREVIEW_OFFSET_Y = 70;
var TYPING_TEXT_OFFSET_HEIGHT = 50;
textStyleBasic.font = "38px Arial";
textStyleBasic.backgroundColor = null;
// done text
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
this.textTypingContentsDone = [];
this.textTypingRecordsDone = [];
@@ -93,10 +110,8 @@ var TypingExamination = {
.addColor(textDoneColor[i], 0);
this.textTypingContentsDone[i].anchor.set(0, 0.5);
var SCORE_POSITION_X = 860;
this.textTypingRecordsDone[i] = game.add.text(
SCORE_POSITION_X, TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
RECORD_POSITION_X, TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
"", textStyleBasic
)
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
@@ -104,6 +119,7 @@ var TypingExamination = {
this.textTypingRecordsDone[i].anchor.set(0.5);
}
// preview text
var textPreviewColor = [ '#999999', '#888888', '#777777' ];
this.textTypingContentPreview = [];
for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) {
@@ -266,6 +282,8 @@ var TypingExamination = {
game.load.onLoadComplete.add(this.literatureLoadComplete, this);
game.load.text("literature", "./../../game/typing/literature_list/korean_national_anthem.txt");
game.load.text("cold_noodle", "./../../game/typing/literature_list/korean_cold_noodle.txt");
game.load.start();
},
@@ -273,7 +291,8 @@ var TypingExamination = {
game.load.onFileComplete.remove(this.loadExaminationContent, this);
game.load.onLoadComplete.remove(this.literatureLoadComplete, this);
var literature = game.cache.getText("literature");
// var literature = game.cache.getText("literature");
var literature = game.cache.getText("cold_noodle");
var examinationContent = literature.split("\n");
for(var i = 0; i < examinationContent.length; i++) {
@@ -285,19 +304,19 @@ var TypingExamination = {
// console.log('playingStageData.level : ' + playingStageData.level);
// console.log('examinationContent : ' + examinationContent);
this.typingRecordForLines = [];
this.typingElapsedTime = [];
for(var i = 0; i < examinationContent.length; i++) {
this.typingRecordForLines[i] = 0;
this.typingElapsedTime[i] = 0;
}
var typingTextMan = new TypingTextManager();
typingTextMan.makeExaminationContents(examinationContent);
this.typingExaminationContents = typingTextMan.getContents();
// console.log(this.typingExaminationContents);
this.typingContentLength = this.typingExaminationContents.length;
this.typingRecordForLines = [];
this.typingElapsedTime = [];
for(var i = 0; i < this.typingContentLength; i++) {
this.typingRecordForLines[i] = 0;
this.typingElapsedTime[i] = 0;
}
this.startGame();
},
@@ -781,7 +800,10 @@ var TypingExamination = {
},
showPlayingWordNumber: function() {
this.contentProgressText.print(this.typingIndex + 1, this.typingContentLength);
// this.contentProgressText.print(this.typingIndex + 1, this.typingContentLength);
var currentLine = this.typingIndex + 1;
this.textTypingLine.text = currentLine + " / " + this.typingContentLength;
},
setTimeTypingStart: function() {