Fix: count uniChar and split sentence, remove BigFontSize

This commit is contained in:
2019-09-13 22:05:32 +09:00
parent 0e8390bfa6
commit 41872447f3
10 changed files with 147 additions and 18 deletions
@@ -45,6 +45,8 @@ function TypingExamButton(x, y) {
this.mainText.anchor.set(0, 0.5);
this.mainText.x = 100;
console.log(this.mainText.width);
// this.mainText.width = 100;
// this.setMainText("");
// this.addIcon("tile_choco");
// this.setIconSize(40);
@@ -116,7 +118,7 @@ TypingExamButton.prototype.setTypingRecordText = function(record) {
}
TypingExamButton.prototype.makeWritingNameText = function() {
var textWidth = 250;
var textWidth = 232;
var style = { };
style.boundsAlignH = "left";
+12 -9
View File
@@ -117,7 +117,7 @@ TypingExamination.prototype.makeDefaultText = function(x, y) {
var defaultText = game.add.text(x, y, "");
defaultText.anchor.set(0, 0.5);
defaultText.font = "Nanum Gothic Coding";
defaultText.fontSize = 26;
defaultText.fontSize = TypingExamination.DEFAULT_FONT_SIZE;
defaultText.fontWeight = "normal";
defaultText.style.fill = "white";
@@ -157,25 +157,26 @@ TypingExamination.prototype.makeInputlineText = function(x, y) {
var CONTENT_TEXT_WIDTH = 800;
var CONTENT_UNDERLINE_OFFSET_Y = 17;
var TYPING_CONTENT_UNDERLINE_OFFSET_Y = 5;
var BIG_FONT_SIZE = 28;
// current text
this.textBackTextOnly = this.makeDefaultText(x, y);
this.textBackTextOnly.fontSize = BIG_FONT_SIZE;
this.textBackTextOnly.fontSize = TypingExamination.DEFAULT_FONT_SIZE;
this.textBackTextOnly.style.fill = TypingExamination.COLOR_NOT_INPUT_STRING;
this.textBackTextOnly.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
console.log(this.textBackTextOnly);
this.textNextLetterIndicator = this.makeDefaultText(x, y);
this.textNextLetterIndicator.fontSize = BIG_FONT_SIZE;
this.textNextLetterIndicator.fontSize = TypingExamination.DEFAULT_FONT_SIZE;
this.textNextLetterIndicator.style.fill = TypingExamination.COLOR_NEXT_INPUT_STRING;
this.textNextLetterIndicator.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
this.textNextLetterIndicator.style.backgroundColor = TypingExamination.COLOR_NEXT_INPUT_BACKGROUND_STRING;
this.textCorrectText = this.makeDefaultText(x, y);
this.textCorrectText.fontSize = BIG_FONT_SIZE;
this.textCorrectText.fontSize = TypingExamination.DEFAULT_FONT_SIZE;
this.textCorrectText.style.fill = TypingExamination.COLOR_CORRECT_INPUT_STRING;
this.textCorrectText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
this.textCorrectText.style.backgroundColor = TypingExamination.COLOR_CORRECT_INPUT_BACKGROUND_STRING;
console.log(this.textCorrectText);
var graphics = game.add.graphics(0, 0);
graphics.lineStyle(1, 0x303030, 1);
@@ -189,7 +190,7 @@ TypingExamination.prototype.makeTextContents = function() {
var CONTENT_TEXT_WIDTH = 800;
var TYPING_CONTENT_X = 150;
var TYPING_CONTENT_Y = 330;
var TYPING_CONTENT_Y = 340;
var LINE_POS_X = 130;
@@ -198,10 +199,9 @@ TypingExamination.prototype.makeTextContents = function() {
var DONE_OFFSET_Y = 0;
var INPUT_OFFSET_Y = 120;
var PREVIEW_OFFSET_Y = 190;
var PREVIEW_OFFSET_Y = 170;
var TEXT_HEIGHT = 50;
var BIG_FONT_SIZE = 28;
// input content
@@ -252,7 +252,7 @@ TypingExamination.prototype.makeTextContents = function() {
this.inputTextContent.anchor.set(0, 0.5);
this.inputTextContent.canvasInput.value('');
this.inputTextContent.canvasInput.focus();
this.inputTextContent.canvasInput.fontSize(BIG_FONT_SIZE);
this.inputTextContent.canvasInput.fontSize(TypingExamination.DEFAULT_FONT_SIZE);
// this.inputTextContent.canvasInput.fontWeight("");
this.inputTextContent.canvasInput.fontFamily("Nanum Gothic Coding");
this.inputTextContent.canvasInput.placeHolder("");
@@ -409,6 +409,7 @@ TypingExamination.prototype.completeLoadingWriting = function() {
game.load.onLoadComplete.remove(this.completeLoadingWriting, this);
var writing = game.cache.getText("writing");
// console.log(writing);
var examinationContent = writing.split("\n");
var count = examinationContent.length;
@@ -745,6 +746,8 @@ TypingExamination.TYPING_CONTENT_PREVIEW_COUNT = 4;
TypingExamination.TYPING_CONTENT_DONE_COUNT = 4;
TypingExamination.TYPING_COUNT_PLUS_ENTER = 1;
TypingExamination.DEFAULT_FONT_SIZE = 26;
TypingExamination.COLOR_NOT_INPUT_STRING = MainColor.DARK_GRAY_STRING;
TypingExamination.COLOR_NEXT_INPUT_STRING = MainColor.GOLD_STRING;
TypingExamination.COLOR_CORRECT_INPUT_STRING = MainColor.YELLOW_STRING;
+7 -2
View File
@@ -105,9 +105,14 @@ TypingTextManager.prototype.makeExaminationContents = function(arr) {
// this.add(arr);
for(var i = 0; i < arr.length; i++) {
var sentence = arr[i];
if(sentence.length == 0)
// console.log(sentence);
// console.log(sentence.length);
var uniCharCount = StringUtil.getUnicodeAlphabetCount(sentence);
if(uniCharCount == 0)
continue;
if(sentence.length > TypingTextManager.SENTENCE_MAX_CHARACTER)
if(uniCharCount > TypingTextManager.SENTENCE_MAX_CHARACTER)
this.add(this.getSplitedSentences(sentence));
else
this.add(sentence);