Fix: highlight animal record text
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
function AnimalList(y) {
|
function AnimalList(posY) {
|
||||||
this.defaultPositionY = y;
|
|
||||||
this.animals = [];
|
this.animals = [];
|
||||||
this.activeAnimalIndex = -1;
|
this.activeAnimalIndex = -1;
|
||||||
|
|
||||||
@@ -14,14 +13,17 @@ function AnimalList(y) {
|
|||||||
|
|
||||||
var bg = game.add.graphics();
|
var bg = game.add.graphics();
|
||||||
bg.beginFill(AnimalList.COLOR_BG, 1);
|
bg.beginFill(AnimalList.COLOR_BG, 1);
|
||||||
bg.drawRect(0, y - 30, GAME_SCREEN_SIZE.x, 80);
|
bg.drawRect(0, posY - 30, GAME_SCREEN_SIZE.x, 80);
|
||||||
|
|
||||||
|
this.recordTextList = this.makeRecordTextList(posY);
|
||||||
|
console.log(this.recordTextList);
|
||||||
|
|
||||||
for(var i = 0; i < animalCount; i++) {
|
for(var i = 0; i < animalCount; i++) {
|
||||||
this.animals[i] = new Animal(
|
this.animals[i] = new Animal(
|
||||||
Animal.TYPE_ICON,
|
Animal.TYPE_ICON,
|
||||||
i,
|
i,
|
||||||
AnimalList.MARGIN_X + offsetAnimal * i,
|
AnimalList.MARGIN_X + offsetAnimal * i,
|
||||||
y
|
posY
|
||||||
);
|
);
|
||||||
this.inactivate(i);
|
this.inactivate(i);
|
||||||
}
|
}
|
||||||
@@ -38,16 +40,20 @@ AnimalList.prototype.activate = function(index) {
|
|||||||
this.animals[this.activeAnimalIndex].setScale(2);
|
this.animals[this.activeAnimalIndex].setScale(2);
|
||||||
this.animals[index].setAlpha(1);
|
this.animals[index].setAlpha(1);
|
||||||
this.animate(this.activeAnimalIndex);
|
this.animate(this.activeAnimalIndex);
|
||||||
|
|
||||||
|
this.recordTextList[index].addColor(AnimalList.COLOR_SCORE_CLEARED_TEXT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimalList.prototype.inactivate = function(index) {
|
AnimalList.prototype.inactivate = function(index) {
|
||||||
this.animals[index].stopAnimation();
|
this.animals[index].stopAnimation();
|
||||||
this.animals[index].setScale(1);
|
this.animals[index].setScale(1);
|
||||||
this.animals[index].setAlpha(AnimalList.ALPHA_INACTIVE);
|
this.animals[index].setAlpha(AnimalList.ALPHA_INACTIVE);
|
||||||
|
|
||||||
|
this.recordTextList[index].addColor(AnimalList.COLOR_SCORE_DEFAULT_TEXT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AnimalList.prototype.printScore = function(type) {
|
AnimalList.prototype.makeRecordTextList = function(posY) {
|
||||||
var animalCount = Animal.SPECIES_DATA.length;
|
var animalCount = Animal.SPECIES_DATA.length;
|
||||||
var lineWidth = GAME_SCREEN_SIZE.x - AnimalList.MARGIN_X * 2;
|
var lineWidth = GAME_SCREEN_SIZE.x - AnimalList.MARGIN_X * 2;
|
||||||
// console.log("lineWidth : " + lineWidth);
|
// console.log("lineWidth : " + lineWidth);
|
||||||
@@ -56,16 +62,17 @@ AnimalList.prototype.printScore = function(type) {
|
|||||||
var titleTextStyle = { font: "16px Arial", fill: "#fff", align: "center"};
|
var titleTextStyle = { font: "16px Arial", fill: "#fff", align: "center"};
|
||||||
var typingCount = 0;
|
var typingCount = 0;
|
||||||
var animalData = null;
|
var animalData = null;
|
||||||
|
var recordTextList = new Array();
|
||||||
for(var i = 0; i < animalCount; i++) {
|
for(var i = 0; i < animalCount; i++) {
|
||||||
animalData = Animal.SPECIES_DATA[i];
|
animalData = Animal.SPECIES_DATA[i];
|
||||||
if(type == AnimalList.TYPE_PRACTICE)
|
if(isTypingPracticeApp())
|
||||||
typingCount = RecordUtil.getRecordValueWithUnit(animalData.practiceTypingCount, 1);
|
typingCount = RecordUtil.getRecordValueWithUnit(animalData.practiceTypingCount, 1);
|
||||||
else
|
else
|
||||||
typingCount = RecordUtil.getRecordValueWithUnit(animalData.testTypingCount, 1);
|
typingCount = RecordUtil.getRecordValueWithUnit(animalData.testTypingCount, 1);
|
||||||
|
|
||||||
var recordText = game.add.text(
|
var recordText = game.add.text(
|
||||||
AnimalList.MARGIN_X + offsetAnimal * i,
|
AnimalList.MARGIN_X + offsetAnimal * i,
|
||||||
this.defaultPositionY + AnimalList.RECORD_TEXT_OFFSET_Y,
|
posY + AnimalList.RECORD_TEXT_OFFSET_Y,
|
||||||
typingCount, titleTextStyle
|
typingCount, titleTextStyle
|
||||||
);
|
);
|
||||||
recordText.anchor.set(0.5);
|
recordText.anchor.set(0.5);
|
||||||
@@ -73,7 +80,10 @@ AnimalList.prototype.printScore = function(type) {
|
|||||||
recordText.stroke = "#333";
|
recordText.stroke = "#333";
|
||||||
recordText.strokeThickness = 3;
|
recordText.strokeThickness = 3;
|
||||||
recordText.setShadow(1, 1, 'rgba(0, 0, 0, 0.5)', 2);
|
recordText.setShadow(1, 1, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
recordTextList.push(recordText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return recordTextList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +113,6 @@ AnimalList.ALPHA_INACTIVE = 0.3;
|
|||||||
AnimalList.TYPE_PRACTICE = 0;
|
AnimalList.TYPE_PRACTICE = 0;
|
||||||
AnimalList.TYPE_TEST = 1;
|
AnimalList.TYPE_TEST = 1;
|
||||||
|
|
||||||
AnimalList.COLOR_BG = 0x444444; // "0x77aadd"; //0x99ccff;
|
AnimalList.COLOR_BG = 0x545454; // "0x77aadd"; //0x99ccff;
|
||||||
AnimalList.COLOR_SCORE_DEFAULT_TEXT = "#dddddd"; //"#bbddff";
|
AnimalList.COLOR_SCORE_DEFAULT_TEXT = "#999999"; // "#dddddd"; //"#bbddff";
|
||||||
AnimalList.COLOR_SCORE_CLEARED_TEXT = "#ffffff";
|
AnimalList.COLOR_SCORE_CLEARED_TEXT = "#ffffff";
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ var TypingPractice = {
|
|||||||
var typingContentBG = new TypingContentBG();
|
var typingContentBG = new TypingContentBG();
|
||||||
typingContentBG.makePracticeContentBG();
|
typingContentBG.makePracticeContentBG();
|
||||||
|
|
||||||
this.animalList = new AnimalList(100);
|
this.animalList = new AnimalList(90);
|
||||||
|
|
||||||
|
|
||||||
var TYPING_CONTENT_Y = 200;
|
var TYPING_CONTENT_Y = 200;
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ var TypingTest = {
|
|||||||
typingContentBG.makeTestContentBG();
|
typingContentBG.makeTestContentBG();
|
||||||
|
|
||||||
this.animalList = new AnimalList(90);
|
this.animalList = new AnimalList(90);
|
||||||
this.animalList.printScore(AnimalList.TYPE_TEST);
|
|
||||||
|
|
||||||
|
|
||||||
var TYPING_CONTENT_Y = 230; // 320;
|
var TYPING_CONTENT_Y = 230; // 320;
|
||||||
|
|||||||
Reference in New Issue
Block a user