Add: RecordUtil
This commit is contained in:
@@ -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 + "초";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user