Esempio n. 1
0
 // triggered when the user presses the "play again" button
 restart(){
   this.score = 0;
   this.offset = 0;
   this.scoreLabel.setText(this.score.toString());
   this.gameover = false;
   Obstacle.reset();
   this.player.reset();
   this.player.jump();
 }
Esempio n. 2
0
 // triggered when the player touches a goal
 goal() {
   // increase score and highscore
   this.score++;
   if (this.score > this.highscore){
     this.highscore = this.score;
   }
   //update score label and center it
   this.scoreLabel.setText(this.score.toString());
   this.scoreLabel.position.set(GameWindow.stageWidth/2 - this.scoreLabel.width/2, 200);
 }