Add: HistoryText

Fix: ranking.js, result.js
This commit is contained in:
2019-06-09 00:21:03 +09:00
parent 547fee6704
commit 1f5f87c361
8 changed files with 127 additions and 72 deletions
+53
View File
@@ -0,0 +1,53 @@
function HistoryText(x, y) {
this.textDate = this.makeDateText(x, y);
this.textDate.anchor.x = 1;
this.textRecord = this.makeRecordText(x, y);
this.textRecord.anchor.x = 1;
};
HistoryText.prototype.makeText = function(x, y, fontStyle) {
var text = game.add.text(x, y, "", fontStyle);
text.anchor.y = 0.5;
text.inputEnabled = false;
text.setShadow(1, 1, 'rgba(32, 32, 32, 1)', 2);
return text;
};
HistoryText.prototype.makeDateText = function(x, y) {
var offsetX = 50;
return this.makeText(x + offsetX, y, HistoryText.FONT_STYLE);
};
HistoryText.prototype.makeRecordText = function(x, y) {
var offsetX = 150;
return this.makeText(x + offsetX, y, HistoryText.FONT_STYLE);
};
HistoryText.prototype.resetText = function(text) {
text.text = "";
text.fill = "#ffffcc";
text.stroke = "#888888";
text.strokeThickness = 2;
};
HistoryText.prototype.reset = function() {
this.resetText(this.textDate);
this.resetText(this.textRecord);
};
HistoryText.prototype.setContents = function(date, record) {
this.reset();
this.textDate.text = DateUtil.printMonthDay(date);
this.textRecord.text = RecordUtil.getRecordValueWithUnit(record, sessionStorageManager.getPlayingAppID());
};
HistoryText.FONT_STYLE = {
font: "19px Arial",
fill: "#ffc"
};
+7 -7
View File
@@ -1,5 +1,4 @@
function RankingText(type, x, y, appID) {
this.type = type;
this.appID = appID;
this.playerID = -1;
@@ -10,14 +9,16 @@ function RankingText(type, x, y, appID) {
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(32, 32, 32, 1)', 2);
if(this.type == RankingText.PLACE_FOR_RANKING)
text.setShadow(3, 3, 'rgba(32, 32, 32, 1)', 2);
else
text.setShadow(1, 1, 'rgba(32, 32, 32, 1)', 2);
return text;
};
@@ -31,7 +32,7 @@ RankingText.prototype.makeRankingText = function(x, y) {
}
else {
fontStyle = RankingText.FONT_STYLE_FOR_RESULT;
offsetX = 10;
offsetX = 30;
}
return this.makeText(x + offsetX, y, fontStyle);
@@ -46,7 +47,7 @@ RankingText.prototype.makePlayerNameText = function(x, y) {
}
else {
fontStyle = RankingText.FONT_STYLE_FOR_RESULT;
offsetX = 20;
offsetX = 40;
}
return this.makeText(x + offsetX, y, fontStyle);
@@ -117,7 +118,6 @@ 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;
@@ -154,7 +154,7 @@ RankingText.FONT_STYLE_FOR_RANKING = {
};
RankingText.FONT_STYLE_FOR_RESULT = {
font: "30px Arial",
font: "19px Arial",
fill: "#fff"
};
+11
View File
@@ -38,4 +38,15 @@ DateUtil.getHHMMSS = function(date) {
return DateUtil.getFullHours(date) + ":"
+ DateUtil.getFullMinutes(date) + ":"
+ DateUtil.getFullSeconds(date);
}
DateUtil.printMonthDay = function(date) {
// var dateTime = new Date(date);
var a = date.split(" ");
var d = a[0].split("-");
var t = "0:0:0".split(":");
if(a.count > 0)
var t = a[1].split(":");
var dateTime = new Date(d[0],(d[1]-1),d[2],t[0],t[1],t[2]);
return DateUtil.getFullMonth(dateTime) + "월 " + DateUtil.getFullDate(dateTime) + "일";
}
-11
View File
@@ -1,17 +1,6 @@
function StringUtil() {
}
StringUtil.printMonthDay = function(date) {
// var dateTime = new Date(date);
var a = date.split(" ");
var d = a[0].split("-");
var t = "0:0:0".split(":");
if(a.count > 0)
var t = a[1].split(":");
var dateTime = new Date(d[0],(d[1]-1),d[2],t[0],t[1],t[2]);
return (dateTime.getMonth() + 1) + "월 " + dateTime.getDate() + "일";
}
StringUtil.getRecordTextWithoutUnit = function(value) {
var number = Math.floor(value);
return NumberUtil.numberWithCommas(number);