Add: typing highest record text in typing buttons
This commit is contained in:
@@ -59,11 +59,42 @@ function TypingAppButton(x, y) {
|
||||
this.keyboardSprite.height = TypingAppButton.KEYBOARD_WIDTH;
|
||||
this.buttonSprite.addChild(this.keyboardSprite);
|
||||
|
||||
this.animal = new Animal(
|
||||
Animal.TYPE_ICON, 0,
|
||||
TypingAppButton.WIDTH - Animal.SPRITE_WIDTH / 2, TypingAppButton.HEIGHT / 2
|
||||
);
|
||||
var animalPosX = TypingAppButton.WIDTH - Animal.SPRITE_WIDTH / 2;
|
||||
var animalPosY = TypingAppButton.HEIGHT / 2 + TypingAppButton.ANIMAL_OFFSET_Y;
|
||||
this.animal = new Animal(Animal.TYPE_ICON, 0, animalPosX, animalPosY);
|
||||
this.buttonSprite.addChild(this.animal.sprite);
|
||||
|
||||
this.typingRecordText = this.makeTypingRecordText(animalPosX, animalPosY + 32);
|
||||
this.buttonSprite.addChild(this.typingRecordText);
|
||||
}
|
||||
|
||||
TypingAppButton.prototype.makeTypingRecordText = function(x, y) {
|
||||
var typingRecordText = game.add.text(x, y, "");
|
||||
typingRecordText.anchor.set(0.5, 0.5);
|
||||
typingRecordText.font = this.setting.font;
|
||||
typingRecordText.fontSize = 13;
|
||||
typingRecordText.style.fill = MainColor.LIGHTER_CHOCO_STRING;
|
||||
typingRecordText.lineSpacing = ButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX;
|
||||
|
||||
return typingRecordText;
|
||||
}
|
||||
|
||||
TypingAppButton.prototype.setTypingRecordText = function(record) {
|
||||
var typingAppID = 1;
|
||||
|
||||
var noDataAlpha = 0.3;
|
||||
if(typeof(record) === "undefined") {
|
||||
this.animal.sprite.alpha = noDataAlpha;
|
||||
this.typingRecordText.style.fill = MainColor.CHOCO_STRING;
|
||||
this.typingRecordText.text = "기록 없음";
|
||||
} else if(record === 0) {
|
||||
this.animal.sprite.alpha = noDataAlpha;
|
||||
this.typingRecordText.style.fill = MainColor.CHOCO_STRING;
|
||||
this.typingRecordText.text = "기록 없음";
|
||||
} else {
|
||||
var recordWithUnit = RecordUtil.getRecordValueWithUnit(record, typingAppID);
|
||||
this.typingRecordText.text = recordWithUnit;
|
||||
}
|
||||
}
|
||||
|
||||
TypingAppButton.prototype.updateKeyboard = function(appID) {
|
||||
@@ -150,7 +181,7 @@ TypingAppButton.prototype.updateKeyboard = function(appID) {
|
||||
TypingAppButton.prototype.updateAnimal = function(highestRecord) {
|
||||
var animalIndex = Animal.animalIndexByRecord(highestRecord, this.appType);
|
||||
this.animal.chagneStandAnimation(animalIndex);
|
||||
this.animal.sprite.y = TypingAppButton.HEIGHT / 2 - Animal.getOffsetY(animalIndex);
|
||||
this.animal.sprite.y = TypingAppButton.HEIGHT / 2 - Animal.getOffsetY(animalIndex) + TypingAppButton.ANIMAL_OFFSET_Y;
|
||||
}
|
||||
|
||||
TypingAppButton.prototype.setInputEnabled = function(isEnabled) {
|
||||
@@ -198,7 +229,7 @@ TypingAppButton.prototype.updateAppData = function(appData) {
|
||||
this.appData = appData;
|
||||
|
||||
this.appGroup = this.appData.appGroup;
|
||||
if(this.appGroup === 0)
|
||||
if(Number(this.appGroup) === 0)
|
||||
this.appType = Animal.TYPE_PRACTICE;
|
||||
else
|
||||
this.appType = Animal.TYPE_TEST;
|
||||
@@ -208,6 +239,7 @@ TypingAppButton.prototype.updateAppData = function(appData) {
|
||||
this.setMainText(this.appData.koreanName);
|
||||
this.setInputEnabled(this.appData.activated);
|
||||
this.updateAnimal(this.appData.highestRecord);
|
||||
this.setTypingRecordText(this.appData.highestRecord);
|
||||
}
|
||||
|
||||
TypingAppButton.prototype.clickEvent = function() {
|
||||
@@ -232,6 +264,8 @@ TypingAppButton.HEIGHT = 80;
|
||||
|
||||
TypingAppButton.KEYBOARD_WIDTH = 100;
|
||||
|
||||
TypingAppButton.ANIMAL_OFFSET_Y = -6;
|
||||
|
||||
TypingAppButton.STROKE_COLOR_OUT_HEX = MainColor.LIGHT_CHOCO_HEX;
|
||||
TypingAppButton.STROKE_COLOR_OVER_HEX = MainColor.LIGHT_CHOCO_HEX;
|
||||
TypingAppButton.STROKE_COLOR_DOWN_HEX = MainColor.LIGHT_CHOCO_HEX;
|
||||
|
||||
@@ -56,11 +56,13 @@ function TypingExamButton(x, y) {
|
||||
this.writingNameText = this.makeWritingNameText();
|
||||
this.buttonSprite.addChild(this.writingNameText);
|
||||
|
||||
this.animal = new Animal(
|
||||
Animal.TYPE_ICON, 0,
|
||||
TypingExamButton.WIDTH - Animal.SPRITE_WIDTH / 2, TypingExamButton.HEIGHT / 2
|
||||
);
|
||||
var animalPosX = TypingExamButton.WIDTH - Animal.SPRITE_WIDTH / 2;
|
||||
var animalPosY = TypingExamButton.HEIGHT / 2 + TypingExamButton.ANIMAL_OFFSET_Y;
|
||||
this.animal = new Animal(Animal.TYPE_ICON, 0, animalPosX, animalPosY);
|
||||
this.buttonSprite.addChild(this.animal.sprite);
|
||||
|
||||
this.typingRecordText = this.makeTypingRecordText(animalPosX, animalPosY + 32);
|
||||
this.buttonSprite.addChild(this.typingRecordText);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,14 +77,43 @@ TypingExamButton.prototype.makeLetterCountText = function() {
|
||||
return letterCountText;
|
||||
}
|
||||
|
||||
TypingExamButton.prototype.makeTypingRecordText = function(x, y) {
|
||||
var typingRecordText = game.add.text(x, y, "");
|
||||
typingRecordText.anchor.set(0.5, 0.5);
|
||||
typingRecordText.font = this.setting.font;
|
||||
typingRecordText.fontSize = 13;
|
||||
typingRecordText.style.fill = MainColor.LIGHTER_CHOCO_STRING;
|
||||
typingRecordText.lineSpacing = ButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX;
|
||||
|
||||
return typingRecordText;
|
||||
}
|
||||
|
||||
TypingExamButton.prototype.setLetterCountText = function(letterCount) {
|
||||
this.letterCountText.y = this.mainText.y;
|
||||
// this.letterCountText.y = this.mainText.y;
|
||||
if(typeof(letterCount) === "undefined")
|
||||
this.letterCountText.text = "";
|
||||
else
|
||||
this.letterCountText.text = "( " + NumberUtil.numberWithCommas(letterCount) + "자 )";
|
||||
}
|
||||
|
||||
TypingExamButton.prototype.setTypingRecordText = function(record) {
|
||||
var typingExamAppID = 200;
|
||||
|
||||
var noDataAlpha = 0.3;
|
||||
if(typeof(record) === "undefined") {
|
||||
this.animal.sprite.alpha = noDataAlpha;
|
||||
this.typingRecordText.style.fill = MainColor.CHOCO_STRING;
|
||||
this.typingRecordText.text = "기록 없음";
|
||||
} else if(record === 0) {
|
||||
this.animal.sprite.alpha = noDataAlpha;
|
||||
this.typingRecordText.style.fill = MainColor.CHOCO_STRING;
|
||||
this.typingRecordText.text = "기록 없음";
|
||||
} else {
|
||||
var recordWithUnit = RecordUtil.getRecordValueWithUnit(record, typingExamAppID);
|
||||
this.typingRecordText.text = recordWithUnit;
|
||||
}
|
||||
}
|
||||
|
||||
TypingExamButton.prototype.makeWritingNameText = function() {
|
||||
var textWidth = 250;
|
||||
|
||||
@@ -114,7 +145,7 @@ TypingExamButton.prototype.setWritingNameText = function(writingName) {
|
||||
TypingExamButton.prototype.updateAnimal = function(highestRecord) {
|
||||
var animalIndex = Animal.animalIndexByRecord(highestRecord, this.appType);
|
||||
this.animal.chagneStandAnimation(animalIndex);
|
||||
this.animal.sprite.y = TypingExamButton.HEIGHT / 2 - Animal.getOffsetY(animalIndex);
|
||||
this.animal.sprite.y = TypingExamButton.HEIGHT / 2 - Animal.getOffsetY(animalIndex) + TypingExamButton.ANIMAL_OFFSET_Y;
|
||||
}
|
||||
|
||||
TypingExamButton.prototype.setInputEnabled = function(isEnabled) {
|
||||
@@ -166,6 +197,7 @@ TypingExamButton.prototype.updateAppData = function(appData) {
|
||||
this.setWritingNameText(this.appData.name);
|
||||
this.setInputEnabled(this.appData.activated);
|
||||
this.updateAnimal(this.appData.highestRecord);
|
||||
this.setTypingRecordText(this.appData.highestRecord);
|
||||
}
|
||||
|
||||
TypingExamButton.prototype.clickEvent = function() {
|
||||
@@ -190,6 +222,8 @@ TypingExamButton.loadResources = function() {
|
||||
TypingExamButton.WIDTH = 400;
|
||||
TypingExamButton.HEIGHT = 80;
|
||||
|
||||
TypingExamButton.ANIMAL_OFFSET_Y = -6;
|
||||
|
||||
TypingExamButton.STROKE_COLOR_OUT_HEX = MainColor.LIGHT_CHOCO_HEX;
|
||||
TypingExamButton.STROKE_COLOR_OVER_HEX = MainColor.LIGHT_CHOCO_HEX;
|
||||
TypingExamButton.STROKE_COLOR_DOWN_HEX = MainColor.LIGHT_CHOCO_HEX;
|
||||
|
||||
@@ -16,11 +16,13 @@ RecordUtil.getRecordValueText = function(record, appID) {
|
||||
}
|
||||
|
||||
RecordUtil.getRecordUnit = function(appID) {
|
||||
if(appID == 104 || appID == 105) // 104 : dodge, 105 : one to fifty
|
||||
var appIDValue = Number(appID);
|
||||
// console.log(appIDValue);
|
||||
if(appIDValue === 104 || appIDValue === 105) // 104 : dodge, 105 : one to fifty
|
||||
return " 초";
|
||||
else if(appID == 52 || appID == 53) // word flyingsaucer
|
||||
else if(appIDValue === 52 || appIDValue === 53) // word flyingsaucer
|
||||
return " 점";
|
||||
else if(appID < 100) // typing
|
||||
else if(appIDValue < 100 || appIDValue === 200) // typing
|
||||
return " 타";
|
||||
else
|
||||
return " 점";
|
||||
|
||||
Reference in New Issue
Block a user