Add: StageTimer

This commit is contained in:
2019-06-21 21:27:49 +09:00
parent a3fb4a57cd
commit f9d5008afc
5 changed files with 84 additions and 42 deletions
+41 -1
View File
@@ -33,6 +33,10 @@ function StageTimer(stageTimerSec, onTimeOver) {
this.bonusTimeText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
};
StageTimer.prototype.setDisplayType = function(type) {
this.displayType = type;
}
StageTimer.prototype.start = function() {
this.timeLeft = this.stageTimerSec;
this.printTime();
@@ -68,7 +72,40 @@ StageTimer.prototype.updateTimer = function() {
}
StageTimer.prototype.printTime = function() {
this.timerText.text = this.timeLeft.toString() + "초";
if(this.displayType == StageTimer.DISPLAY_TYPE_SEC) {
this.timerText.text = this.timeLeft.toString() + "초";
return;
}
var hours = Math.floor(this.timeLeft / 60 / 60);
var minutes = Math.floor(this.timeLeft / 60);
var seconds = this.timeLeft % 60;
// console.log("hours : " + hours);
// console.log("minutes : " + minutes);
// console.log("seconds : " + seconds);
this.timerText.text = "";
var timeText = "";
if(hours > 0)
timeText = hours + "시간";
if(minutes > 0) {
if(timeText != "")
timeText += " ";
timeText = minutes + "분";
}
if(seconds > 0) {
if(timeText != "")
timeText += " ";
timeText += seconds + "초";
}
this.timerText.text = timeText;
}
StageTimer.prototype.removeTimer = function() {
@@ -94,6 +131,9 @@ StageTimer.prototype.addBonusTime = function(timeSec) {
}
StageTimer.DISPLAY_TYPE_NON_SEC = 0;
StageTimer.DISPLAY_TYPE_SEC = 1;
StageTimer.FONT_HEIGHT_PX = 70;
StageTimer.DEFAULT_TEXT_FONT = {