Fix: make text methods
This commit is contained in:
@@ -82,7 +82,41 @@ TypingExamination.prototype.fontLoaded = function() {
|
|||||||
// this.animalRecordList.hide();
|
// this.animalRecordList.hide();
|
||||||
this.animalRecordList.applyLoadedFont();
|
this.animalRecordList.applyLoadedFont();
|
||||||
|
|
||||||
|
this.makeTextContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
TypingExamination.prototype.makeUnderlineText = function(x, y) {
|
||||||
|
var CONTENT_TEXT_WIDTH = 800;
|
||||||
|
var CONTENT_UNDERLINE_OFFSET_Y = 17;
|
||||||
|
|
||||||
|
var graphics = game.add.graphics(0, 0);
|
||||||
|
graphics.lineStyle(1, 0x303030, 1);
|
||||||
|
graphics.moveTo(x, y + CONTENT_UNDERLINE_OFFSET_Y);
|
||||||
|
graphics.lineTo(x + CONTENT_TEXT_WIDTH, y + CONTENT_UNDERLINE_OFFSET_Y);
|
||||||
|
|
||||||
|
var underlineText = game.add.text(x, y, "");
|
||||||
|
underlineText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||||
|
underlineText.anchor.set(0, 0.5);
|
||||||
|
underlineText.font = "Nanum Gothic Coding";
|
||||||
|
underlineText.fontSize = 26;
|
||||||
|
underlineText.fontWeight = "normal";
|
||||||
|
underlineText.style.fill = "white";
|
||||||
|
|
||||||
|
return underlineText;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypingExamination.prototype.makeLineText = function(x, y) {
|
||||||
|
var lineText = game.add.text(x, y, "");
|
||||||
|
lineText.anchor.set(1, 0.5);
|
||||||
|
lineText.font = "Nanum Gothic Coding";
|
||||||
|
lineText.fontSize = 26;
|
||||||
|
lineText.fontWeight = "normal";
|
||||||
|
lineText.style.fill = "white";
|
||||||
|
|
||||||
|
return lineText;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypingExamination.prototype.makeTextContents = function() {
|
||||||
// typing content
|
// typing content
|
||||||
var CONTENT_TEXT_WIDTH = 800;
|
var CONTENT_TEXT_WIDTH = 800;
|
||||||
var CONTENT_UNDERLINE_OFFSET = 17;
|
var CONTENT_UNDERLINE_OFFSET = 17;
|
||||||
@@ -116,7 +150,7 @@ TypingExamination.prototype.fontLoaded = function() {
|
|||||||
this.textTypedContentBack = game.add.text(
|
this.textTypedContentBack = game.add.text(
|
||||||
TYPING_CONTENT_X, TYPING_CONTENT_Y,
|
TYPING_CONTENT_X, TYPING_CONTENT_Y,
|
||||||
"", textStyleBasic
|
"", textStyleBasic
|
||||||
)
|
);
|
||||||
// .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.textTypedContentBack.anchor.set(0, 0.5);
|
this.textTypedContentBack.anchor.set(0, 0.5);
|
||||||
@@ -175,34 +209,16 @@ TypingExamination.prototype.fontLoaded = function() {
|
|||||||
this.textTypingContentsDone = [];
|
this.textTypingContentsDone = [];
|
||||||
this.textTypingRecordsDone = [];
|
this.textTypingRecordsDone = [];
|
||||||
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
|
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||||
graphics.moveTo(
|
this.textTypingContentsDone[i] = this.makeUnderlineText(
|
||||||
TYPING_CONTENT_X,
|
TYPING_CONTENT_X,
|
||||||
TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT + CONTENT_UNDERLINE_OFFSET
|
TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
|
||||||
);
|
);
|
||||||
graphics.lineTo(
|
this.textTypingContentsDone[i].style.backgroundColor = TypingExamination.INPUT_CONTENT_BACKGROUND_COLOR;
|
||||||
TYPING_CONTENT_X + CONTENT_TEXT_WIDTH,
|
|
||||||
TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT + CONTENT_UNDERLINE_OFFSET
|
this.textTypingRecordsDone[i] = this.makeLineText(
|
||||||
|
RECORD_POSITION_X,
|
||||||
|
TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
|
||||||
);
|
);
|
||||||
|
|
||||||
textStyleBasic.font = "38px Nanum Gothic Coding";
|
|
||||||
this.textTypingContentsDone[i] = game.add.text(
|
|
||||||
TYPING_CONTENT_X, TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
|
|
||||||
"", textStyleBasic
|
|
||||||
)
|
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
|
||||||
.addColor(textDoneColor[i], 0);
|
|
||||||
this.textTypingContentsDone[i].anchor.set(0, 0.5);
|
|
||||||
this.textTypingContentsDone[i].fontSize = FONT_SIZE;
|
|
||||||
|
|
||||||
textStyleBasic.font = "38px Nanum Gothic Coding";
|
|
||||||
this.textTypingRecordsDone[i] = game.add.text(
|
|
||||||
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)
|
|
||||||
.addColor(textDoneColor[i], 0);
|
|
||||||
this.textTypingRecordsDone[i].anchor.set(1, 0.5);
|
|
||||||
this.textTypingRecordsDone[i].fontSize = FONT_SIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// preview text
|
// preview text
|
||||||
@@ -211,35 +227,15 @@ TypingExamination.prototype.fontLoaded = function() {
|
|||||||
this.textTypingContentPreview = [];
|
this.textTypingContentPreview = [];
|
||||||
this.textLineNumber = [];
|
this.textLineNumber = [];
|
||||||
for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||||
graphics.moveTo(
|
this.textTypingContentPreview[i] = this.makeUnderlineText(
|
||||||
TYPING_CONTENT_X,
|
|
||||||
TYPING_CONTENT_Y + TYPING_OFFSET_Y + TYPING_PREVIEW_OFFSET_Y + i * TYPING_TEXT_OFFSET_HEIGHT + CONTENT_UNDERLINE_OFFSET
|
|
||||||
);
|
|
||||||
graphics.lineTo(
|
|
||||||
TYPING_CONTENT_X + CONTENT_TEXT_WIDTH,
|
|
||||||
TYPING_CONTENT_Y + TYPING_OFFSET_Y + TYPING_PREVIEW_OFFSET_Y + i * TYPING_TEXT_OFFSET_HEIGHT + CONTENT_UNDERLINE_OFFSET
|
|
||||||
);
|
|
||||||
|
|
||||||
textStyleBasic.font = "38px Nanum Gothic Coding";
|
|
||||||
this.textTypingContentPreview[i] = game.add.text(
|
|
||||||
TYPING_CONTENT_X,
|
TYPING_CONTENT_X,
|
||||||
TYPING_CONTENT_Y + TYPING_OFFSET_Y + TYPING_PREVIEW_OFFSET_Y + i * TYPING_TEXT_OFFSET_HEIGHT,
|
TYPING_CONTENT_Y + TYPING_OFFSET_Y + TYPING_PREVIEW_OFFSET_Y + i * TYPING_TEXT_OFFSET_HEIGHT,
|
||||||
"", textStyleBasic
|
);
|
||||||
)
|
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
|
||||||
.addColor(textPreviewColor[i], 0);
|
|
||||||
this.textTypingContentPreview[i].anchor.set(0, 0.5);
|
|
||||||
this.textTypingContentPreview[i].fontSize = FONT_SIZE;
|
|
||||||
|
|
||||||
this.textLineNumber[i] = game.add.text(
|
this.textLineNumber[i] = this.makeLineText(
|
||||||
RECORD_POSITION_X,
|
RECORD_POSITION_X,
|
||||||
TYPING_CONTENT_Y + TYPING_OFFSET_Y + TYPING_PREVIEW_OFFSET_Y + i * TYPING_TEXT_OFFSET_HEIGHT,
|
TYPING_CONTENT_Y + TYPING_OFFSET_Y + TYPING_PREVIEW_OFFSET_Y + i * TYPING_TEXT_OFFSET_HEIGHT,
|
||||||
"", textStyleBasic
|
);
|
||||||
)
|
|
||||||
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
|
||||||
// .addColor(textDoneColor[i], 0);
|
|
||||||
this.textLineNumber[i].anchor.set(1, 0.5);
|
|
||||||
this.textLineNumber[i].fontSize = FONT_SIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user