Add: RankingText
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
function RankingText(type, x, y, appID) {
|
||||
|
||||
this.type = type;
|
||||
this.appID = appID;
|
||||
this.playerID = -1;
|
||||
|
||||
this.textRanking = this.makeRankingText(x, y);
|
||||
this.textRanking.anchor.x = 1;
|
||||
this.textPlayerName = this.makePlayerNameText(x, y);
|
||||
this.textPlayerName.anchor.x = 0;
|
||||
this.textRecord = this.makeRecordText(x, y);
|
||||
this.textRecord.anchor.x = 1;
|
||||
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
RankingText.prototype.makeRankingText = function(x, y) {
|
||||
var fontStyle = null;
|
||||
var offsetX = 0;
|
||||
if(this.type == RankingText.PLACE_FOR_RANKING) {
|
||||
fontStyle = RankingText.FONT_STYLE_FOR_RANKING;
|
||||
offsetX = 40;
|
||||
}
|
||||
else {
|
||||
fontStyle = RankingText.FONT_STYLE_FOR_RESULT;
|
||||
offsetX = 10;
|
||||
}
|
||||
|
||||
return this.makeText(x + offsetX, y, fontStyle);
|
||||
};
|
||||
|
||||
RankingText.prototype.makePlayerNameText = function(x, y) {
|
||||
var fontStyle = null;
|
||||
var offsetX = 0;
|
||||
if(this.type == RankingText.PLACE_FOR_RANKING) {
|
||||
fontStyle = RankingText.FONT_STYLE_FOR_RANKING;
|
||||
offsetX = 70;
|
||||
}
|
||||
else {
|
||||
fontStyle = RankingText.FONT_STYLE_FOR_RESULT;
|
||||
offsetX = 20;
|
||||
}
|
||||
|
||||
return this.makeText(x + offsetX, y, fontStyle);
|
||||
};
|
||||
|
||||
RankingText.prototype.makeRecordText = function(x, y) {
|
||||
var fontStyle = null;
|
||||
var offsetX = 0;
|
||||
if(this.type == RankingText.PLACE_FOR_RANKING) {
|
||||
fontStyle = RankingText.FONT_STYLE_FOR_RANKING;
|
||||
offsetX = 340;
|
||||
}
|
||||
else {
|
||||
fontStyle = RankingText.FONT_STYLE_FOR_RESULT;
|
||||
offsetX = 200;
|
||||
}
|
||||
|
||||
return this.makeText(x + offsetX, y, fontStyle);
|
||||
};
|
||||
|
||||
RankingText.prototype.reset = function() {
|
||||
this.playerID = -1;
|
||||
this.textRanking.text = "";
|
||||
this.textPlayerName.text = "";
|
||||
this.textRecord.text = "";
|
||||
};
|
||||
|
||||
RankingText.prototype.setContents = function(playerID, ranking, playerName, record) {
|
||||
this.reset();
|
||||
|
||||
this.playerID = playerID;
|
||||
this.textRanking.text = ranking + "등";
|
||||
this.textPlayerName.text = playerName;
|
||||
this.setRecord(record, this.appID);
|
||||
};
|
||||
|
||||
RankingText.prototype.setRecord = function(record, appID) {
|
||||
this.textRecord.text = RecordUtil.getRecordValueWithUnit(record, appID);
|
||||
};
|
||||
|
||||
|
||||
|
||||
RankingText.FONT_STYLE_FOR_RANKING = {
|
||||
font: "32px Arial",
|
||||
fill: "#fff"
|
||||
};
|
||||
|
||||
RankingText.FONT_STYLE_FOR_RESULT = {
|
||||
font: "30px Arial",
|
||||
fill: "#fff"
|
||||
};
|
||||
|
||||
RankingText.PLACE_FOR_RANKING = 0;
|
||||
RankingText.PLACE_FOR_RESULT = 1;
|
||||
Reference in New Issue
Block a user