Add: RecordUtil

This commit is contained in:
2018-12-03 00:25:16 +09:00
parent 057ac18184
commit eb61871526
12 changed files with 92 additions and 270 deletions
+8 -13
View File
@@ -1,13 +1,12 @@
function StopWatch() {
this.ellpasedTime = 0;
this.startTime = 0;
this.isPaused = true;
var fontStyle = StopWatch.DEFAULT_TEXT_FONT;
fontStyle.align = "right";
fontStyle.boundsAlignH = "right";
this.timerText = game.add.text(game.world.width - 200, 35, "", fontStyle);
this.timerText.anchor.set(0, 0.5);
this.timerText = game.add.text(game.world.centerX, 35, "", fontStyle);
this.timerText.anchor.set(0.5);
// var grd = this.label.context.createLinearGradient(0, 0, 0, StopWatch.FONT_HEIGHT_PX);
// grd.addColorStop(0, '#8ED6FF');
@@ -20,15 +19,16 @@ function StopWatch() {
// this.label.strokeThickness = 3;
this.timerEvent = null;
};
}
StopWatch.prototype.start = function() {
this.isPaused = false;
this.startTime = game.time.totalElapsedSeconds();
console.log(this.startTime);
this.printTime();
if(this.timerEvent === null)
this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND / 10, this.updateTimer, this);
this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND / 100, this.updateTimer, this);
}
StopWatch.prototype.pause = function() {
@@ -57,12 +57,7 @@ StopWatch.prototype.updateTimer = function() {
}
StopWatch.prototype.printTime = function() {
var ellapsedTimeText = this.ellpasedTime.toString();
var timeText = "";
if(ellapsedTimeText.length == 1)
timeText = ellapsedTimeText + ".0";
else
timeText = ellapsedTimeText.substring(0, 3);
var timeText = this.ellpasedTime.toFixed(2);
this.timerText.text = timeText + "초";
}