Fix: change timer, update time -> real time
This commit is contained in:
@@ -57,7 +57,7 @@ var Game = {
|
||||
// if previous record is over 60 sec, play easy mode
|
||||
var prevRecord = sessionStorageManager.getRecord()
|
||||
// console.log(prevRecord);
|
||||
var secForEasyMode = this.mode == "test" ? 1 : 40;
|
||||
var secForEasyMode = this.mode == "test" ? 1 : 60;
|
||||
if(prevRecord > secForEasyMode) {
|
||||
this.difficulty = Chocoball.MODE_EASY;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
function StopWatch() {
|
||||
this.startTime = 0;
|
||||
this.ellapsedTime = 0;
|
||||
// this.startTime = 0;
|
||||
this.isPaused = true;
|
||||
|
||||
var fontStyle = StopWatch.DEFAULT_TEXT_FONT;
|
||||
@@ -24,7 +24,10 @@ function StopWatch() {
|
||||
|
||||
StopWatch.prototype.start = function() {
|
||||
this.isPaused = false;
|
||||
// this.startTime = game.time.totalElapsedSeconds();
|
||||
this.startTime = game.time.totalElapsedSeconds();
|
||||
|
||||
// this.startTime = new Date();
|
||||
console.log(this.startTime);
|
||||
|
||||
this.ellapsedTimer = game.time.create(false);
|
||||
this.timerEvent = this.ellapsedTimer.loop(10, this.updateTimer, this);
|
||||
@@ -44,19 +47,21 @@ StopWatch.prototype.resume = function() {
|
||||
}
|
||||
|
||||
StopWatch.prototype.stop = function() {
|
||||
// var recordTime = game.time.totalElapsedSeconds() - this.startTime;
|
||||
var recordTime = game.time.totalElapsedSeconds() - this.startTime;
|
||||
this.removeTimer();
|
||||
|
||||
// return recordTime;
|
||||
return this.ellapsedTime;
|
||||
return recordTime;
|
||||
// return this.ellapsedTime;
|
||||
}
|
||||
|
||||
StopWatch.prototype.updateTimer = function() {
|
||||
if(this.isPaused == true)
|
||||
return;
|
||||
|
||||
// this.ellapsedTime = game.time.totalElapsedSeconds() - this.startTime;
|
||||
this.ellapsedTime += 0.01;
|
||||
this.ellapsedTime = game.time.totalElapsedSeconds() - this.startTime;
|
||||
// console.log(this.ellapsedTime);
|
||||
// this.ellapsedTime += 0.01;
|
||||
|
||||
this.printTime();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user