Fix: change timer, update time -> real time

This commit is contained in:
2019-05-11 17:04:03 +09:00
parent 418d3ec960
commit a1cfca5890
2 changed files with 13 additions and 8 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ var Game = {
// if previous record is over 60 sec, play easy mode // if previous record is over 60 sec, play easy mode
var prevRecord = sessionStorageManager.getRecord() var prevRecord = sessionStorageManager.getRecord()
// console.log(prevRecord); // console.log(prevRecord);
var secForEasyMode = this.mode == "test" ? 1 : 40; var secForEasyMode = this.mode == "test" ? 1 : 60;
if(prevRecord > secForEasyMode) { if(prevRecord > secForEasyMode) {
this.difficulty = Chocoball.MODE_EASY; this.difficulty = Chocoball.MODE_EASY;
} }
+12 -7
View File
@@ -1,6 +1,6 @@
function StopWatch() { function StopWatch() {
this.startTime = 0;
this.ellapsedTime = 0; this.ellapsedTime = 0;
// this.startTime = 0;
this.isPaused = true; this.isPaused = true;
var fontStyle = StopWatch.DEFAULT_TEXT_FONT; var fontStyle = StopWatch.DEFAULT_TEXT_FONT;
@@ -24,7 +24,10 @@ function StopWatch() {
StopWatch.prototype.start = function() { StopWatch.prototype.start = function() {
this.isPaused = false; 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.ellapsedTimer = game.time.create(false);
this.timerEvent = this.ellapsedTimer.loop(10, this.updateTimer, this); this.timerEvent = this.ellapsedTimer.loop(10, this.updateTimer, this);
@@ -44,19 +47,21 @@ StopWatch.prototype.resume = function() {
} }
StopWatch.prototype.stop = function() { StopWatch.prototype.stop = function() {
// var recordTime = game.time.totalElapsedSeconds() - this.startTime; var recordTime = game.time.totalElapsedSeconds() - this.startTime;
this.removeTimer(); this.removeTimer();
// return recordTime; return recordTime;
return this.ellapsedTime; // return this.ellapsedTime;
} }
StopWatch.prototype.updateTimer = function() { StopWatch.prototype.updateTimer = function() {
if(this.isPaused == true) if(this.isPaused == true)
return; return;
// this.ellapsedTime = game.time.totalElapsedSeconds() - this.startTime; this.ellapsedTime = game.time.totalElapsedSeconds() - this.startTime;
this.ellapsedTime += 0.01; // console.log(this.ellapsedTime);
// this.ellapsedTime += 0.01;
this.printTime(); this.printTime();
} }