In this task, we create a scene that lets the player choose which level they want to play.
We have defined many levels with different types of obstacles. The following figure shows the structure of the LevelSelection
symbol:
We also create a ScoreBoard
symbol that contains a text field:
We have prepared the graphics. Let's work on the code to add the level-choosing logic:
This is something related to the view, so we will put the code in the
view.js
file. The graphics are already defined and exported. We create the following method to showscoreBoard
in the game scene. Thescoreboard
symbol shows the player's score:game.view.showScoreBoard = function(){ this.scoreBoard = new lib.ScoreBoard(); this.scoreBoard.x = 10; this.scoreBoard.y = 10; game.stage.addChild(this.scoreBoard); };
We create the following function to update the text with the latest score:
game.view.updateScore = function() { this.scoreBoard.textField.text = game.score...