fix: timer

This commit is contained in:
Renge 2022-04-23 21:54:28 -04:00
parent 8e68d60dba
commit 17afceee47
2 changed files with 15 additions and 16 deletions

View File

@ -266,25 +266,25 @@ export default class GameLevel extends Scene {
if (this.gameStateStack.peek() === GameState.GAMING) {
if (this.gameStarted) {
GameLevel.gameTimer += deltaT;
let minutes = Math.floor(GameLevel.gameTimer / 60);
if (minutes >= 10) {
this.timerLable.text = minutes.toString();
}
else {
this.timerLable.text = "0" + minutes.toString();
}
let seconds = Math.floor(GameLevel.gameTimer % 60);
if (seconds >= 10) {
this.timerLable.text += ":" + seconds.toString();
}
else {
this.timerLable.text += ":0" + seconds.toString();
}
this.timerLable.textColor = Color.BLACK;
}
else {
this.timerLable.textColor = Color.RED;
}
let minutes = Math.floor(GameLevel.gameTimer / 60);
if (minutes >= 10) {
this.timerLable.text = minutes.toString();
}
else {
this.timerLable.text = "0" + minutes.toString();
}
let seconds = Math.floor(GameLevel.gameTimer % 60);
if (seconds >= 10) {
this.timerLable.text += ":" + seconds.toString();
}
else {
this.timerLable.text += ":0" + seconds.toString();
}
}
// Handle events and update the UI if needed
@ -1075,7 +1075,6 @@ export default class GameLevel extends Scene {
this.touchedStartCheckPoint = true;
this.storyLoader("shattered_sword_assets/jsons/story.json");
this.startTimer();
this.levelEnded = true;
}
}

View File

@ -59,6 +59,6 @@ export default class Tutorial extends GameLevel {
protected goToNextLevel(): void {
this.viewport.setZoomLevel(1);
this.sceneManager.changeToScene(MainMenu);
this.sceneManager.changeToScene(Porcelain);
}
}