Fix: stop watch for 1to50
This commit is contained in:
@@ -9,14 +9,14 @@ RecordUtil.getRecordValueWithUnit = function(record, appID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RecordUtil.getRecordValueText = function(record, appID) {
|
RecordUtil.getRecordValueText = function(record, appID) {
|
||||||
if(appID == 104)
|
if(appID == 104 || appID == 105)
|
||||||
return record.toFixed(2);
|
return record.toFixed(2);
|
||||||
else
|
else
|
||||||
return NumberUtil.numberWithCommas(Math.floor(record));
|
return NumberUtil.numberWithCommas(Math.floor(record));
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordUtil.getRecordUnit = function(appID) {
|
RecordUtil.getRecordUnit = function(appID) {
|
||||||
if(appID == 104) // dodge
|
if(appID == 104 || appID == 105) // dodge
|
||||||
return " 초";
|
return " 초";
|
||||||
else if(appID == 52 || appID == 53) // word flyingsaucer
|
else if(appID == 52 || appID == 53) // word flyingsaucer
|
||||||
return " 점";
|
return " 점";
|
||||||
|
|||||||
@@ -27,22 +27,7 @@ var Game = {
|
|||||||
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
|
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
|
||||||
screenTopUI.makeFullScreenButton();
|
screenTopUI.makeFullScreenButton();
|
||||||
|
|
||||||
this.scoreManager = new ScoreManager();
|
this.stopWatch = new StopWatch(game);
|
||||||
this.scoreBoard = new ScoreBoard();
|
|
||||||
this.scoreManager.addOnChangeScoreListener(
|
|
||||||
(function(score) {
|
|
||||||
sessionStorageManager.setRecord(score);
|
|
||||||
this.scoreBoard.printScore(NumberUtil.numberWithCommas(score));
|
|
||||||
}).bind(this)
|
|
||||||
);
|
|
||||||
this.scoreManager.addOnChangeHighScoreListener(
|
|
||||||
(function(highScore) {
|
|
||||||
// console.log(highScore);
|
|
||||||
// sessionStorageManager.setAppHighestRecord(highScore);
|
|
||||||
sessionStorageManager.setIsNewBestRecrd(true);
|
|
||||||
// this.screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
|
|
||||||
}).bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
this.initVariables();
|
this.initVariables();
|
||||||
@@ -73,10 +58,16 @@ var Game = {
|
|||||||
|
|
||||||
|
|
||||||
startGame: function() {
|
startGame: function() {
|
||||||
this.startStage();
|
this.stopWatch.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
startStage: function() {
|
gameClear: function() {
|
||||||
|
var recordTime = this.stopWatch.stop();
|
||||||
|
sessionStorageManager.setRecord(recordTime);
|
||||||
|
if(!isExperienceMaestroAccount())
|
||||||
|
this.updateResultRecord();
|
||||||
|
|
||||||
|
game.time.events.add(Game.GAME_OVER_WAIT_TIME_MS, this.goResult, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
timeOver: function() {
|
timeOver: function() {
|
||||||
@@ -84,7 +75,12 @@ var Game = {
|
|||||||
if(!isExperienceMaestroAccount())
|
if(!isExperienceMaestroAccount())
|
||||||
this.updateResultRecord();
|
this.updateResultRecord();
|
||||||
|
|
||||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
var recordTime = this.stopWatch.stop();
|
||||||
|
sessionStorageManager.setRecord(recordTime);
|
||||||
|
if(!isExperienceMaestroAccount())
|
||||||
|
this.updateResultRecord();
|
||||||
|
|
||||||
|
game.time.events.add(Game.GAME_OVER_WAIT_TIME_MS, this.goResult, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateResultRecord: function() {
|
updateResultRecord: function() {
|
||||||
@@ -105,5 +101,6 @@ var Game = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Game.GAME_OVER_WAIT_TIME_MS = 3000;
|
||||||
// Game.GAME_TIME_SEC = 60;
|
// Game.GAME_TIME_SEC = 60;
|
||||||
// Game.NEXT_STAGE_DELAY_MS = 500;
|
// Game.NEXT_STAGE_DELAY_MS = 500;
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
function StopWatch() {
|
||||||
|
this.ellapsedTime = 0;
|
||||||
|
// this.startTime = 0;
|
||||||
|
this.isPaused = true;
|
||||||
|
|
||||||
|
var fontStyle = StopWatch.DEFAULT_TEXT_FONT;
|
||||||
|
|
||||||
|
this.timerText = game.add.text(game.world.centerX, 35, "", fontStyle);
|
||||||
|
this.timerText.anchor.set(0.5);
|
||||||
|
this.printTime();
|
||||||
|
|
||||||
|
// var grd = this.label.context.createLinearGradient(0, 0, 0, StopWatch.FONT_HEIGHT_PX);
|
||||||
|
// grd.addColorStop(0, '#8ED6FF');
|
||||||
|
// grd.addColorStop(1, '#004CB3');
|
||||||
|
// this.label.fill = grd;
|
||||||
|
// this.scoreText.fill = grd;
|
||||||
|
|
||||||
|
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
// this.label.stroke = '#000';
|
||||||
|
// this.label.strokeThickness = 3;
|
||||||
|
|
||||||
|
this.timerEvent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
StopWatch.prototype.start = function() {
|
||||||
|
this.isPaused = false;
|
||||||
|
// this.startTime = game.time.totalElapsedSeconds();
|
||||||
|
|
||||||
|
this.ellapsedTimer = game.time.create(false);
|
||||||
|
this.timerEvent = this.ellapsedTimer.loop(10, this.updateTimer, this);
|
||||||
|
this.ellapsedTimer.start();
|
||||||
|
|
||||||
|
this.printTime();
|
||||||
|
|
||||||
|
// this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND / 100, this.updateTimer, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopWatch.prototype.pause = function() {
|
||||||
|
this.isPaused = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
StopWatch.prototype.resume = function() {
|
||||||
|
this.isPaused = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
StopWatch.prototype.stop = function() {
|
||||||
|
// var recordTime = game.time.totalElapsedSeconds() - this.startTime;
|
||||||
|
this.removeTimer();
|
||||||
|
|
||||||
|
// 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.printTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
StopWatch.prototype.printTime = function() {
|
||||||
|
this.timerText.text = RecordUtil.getRecordValueWithUnit(
|
||||||
|
this.ellapsedTime, sessionStorageManager.getPlayingAppID()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopWatch.prototype.removeTimer = function() {
|
||||||
|
game.time.events.remove(this.timerEvent);
|
||||||
|
if(this.timerEvent)
|
||||||
|
this.timerEvent = null;
|
||||||
|
|
||||||
|
this.ellapsedTimer.stop();
|
||||||
|
this.ellapsedTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
StopWatch.FONT_HEIGHT_PX = 70;
|
||||||
|
|
||||||
|
StopWatch.DEFAULT_TEXT_FONT = {
|
||||||
|
font: "38px Arial",
|
||||||
|
align: "center",
|
||||||
|
boundsAlignH: "center", // left, center. right
|
||||||
|
boundsAlignV: "middle", // top, middle, bottom
|
||||||
|
fill: "#fff"
|
||||||
|
};
|
||||||
@@ -65,6 +65,8 @@
|
|||||||
<!-- Space Invaders : source files -->
|
<!-- Space Invaders : source files -->
|
||||||
<script src="../../game/mouse/one_to_fifty/loading.js"></script>
|
<script src="../../game/mouse/one_to_fifty/loading.js"></script>
|
||||||
|
|
||||||
|
<script src="../../game/mouse/one_to_fifty/stop_watch.js"></script>
|
||||||
|
|
||||||
<script src="../../game/mouse/one_to_fifty/game.js"></script>
|
<script src="../../game/mouse/one_to_fifty/game.js"></script>
|
||||||
<script src="../../game/mouse/one_to_fifty/main.js"></script>
|
<script src="../../game/mouse/one_to_fifty/main.js"></script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user