Add: ranking text color

This commit is contained in:
2019-06-08 08:43:36 +09:00
parent 7ab5d1020b
commit 547fee6704
2 changed files with 63 additions and 5 deletions
+63 -4
View File
@@ -17,7 +17,7 @@ RankingText.prototype.makeText = function(x, y, fontStyle) {
var text = game.add.text(x, y, "", fontStyle);
text.anchor.y = 0.5;
text.inputEnabled = false;
text.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
text.setShadow(3, 3, 'rgba(32, 32, 32, 1)', 2);
return text;
};
@@ -67,11 +67,68 @@ RankingText.prototype.makeRecordText = function(x, y) {
return this.makeText(x + offsetX, y, fontStyle);
};
RankingText.prototype.resetText = function(text) {
text.text = "";
text.fill = "#ffffff";
text.stroke = "#888888";
text.strokeThickness = 2;
};
RankingText.prototype.reset = function() {
this.playerID = -1;
this.textRanking.text = "";
this.textPlayerName.text = "";
this.textRecord.text = "";
this.resetText(this.textRanking);
this.resetText(this.textPlayerName);
this.resetText(this.textRecord);
};
RankingText.prototype.setTextRankingColor = function(text, ranking) {
var fillColor = "";
var strokeColor = "";
switch(ranking) {
case 1:
fillColor = "#ffd700"; // gold
strokeColor = "#cd853f";
break;
case 2:
fillColor = "#d0d0d0"; // silver
strokeColor = "#404040";
break;
case 3:
fillColor = "#d2691e"; // bronze
strokeColor = "#8b0000";
break;
}
text.fill = fillColor;
text.stroke = strokeColor;
text.strokeThickness = 2;
};
RankingText.prototype.setTopRankingTextColor = function(ranking) {
if(ranking < 4) {
this.setTextRankingColor(this.textRanking, ranking);
this.setTextRankingColor(this.textPlayerName, ranking);
this.setTextRankingColor(this.textRecord, ranking);
}
};
RankingText.prototype.setMyRankingTextColor = function() {
if(sessionStorageManager.getPlayerID() != this.playerID)
return;
console.log(this.playerID);
var fillColor = "#9acd32"; // yellowgreen
var strokeColor = "#2e8b57"; // seagreen
this.textRanking.fill = fillColor;
this.textRanking.stroke = strokeColor;
this.textRanking.strokeThickness = 2;
this.textPlayerName.fill = fillColor;
this.textPlayerName.stroke = strokeColor;
this.textPlayerName.strokeThickness = 2;
this.textRecord.fill = fillColor;
this.textRecord.stroke = strokeColor;
this.textRecord.strokeThickness = 2;
};
RankingText.prototype.setContents = function(playerID, ranking, playerName, record) {
@@ -81,6 +138,8 @@ RankingText.prototype.setContents = function(playerID, ranking, playerName, reco
this.textRanking.text = ranking + "등";
this.textPlayerName.text = playerName;
this.setRecord(record, this.appID);
this.setMyRankingTextColor();
this.setTopRankingTextColor(ranking);
};
RankingText.prototype.setRecord = function(record, appID) {