HTML and CSS Reference
In-Depth Information
Showing different quests
In this task, we are going to show how to advance to the next level when the player's
composiion matches that of the quest composiions in the current level.
Engage thrusters
This ime, we need quest-level data in the quest.js file to be accessible from another file,
so we need to atach the questLevels and questData methods to the game scope rather
than the original local scope:
1. In the quest.js file, we change the questLevels declaraion from var
questLevels to game.questLevels .
2. We apply the same to questData :
// from
var questData = questLevels[level];
// to
var questData = game.questLevels[level];
3. In the scenes.js ile, we display the level with the following funcion:
gameScene.updateLevelInfo = function(level) {
document.getElementById('stage').textContent = "Stage "
+ level;
};
4. At last, we modify the game flow in the game.js file to count the level:
game.flow = {
currentLevel: -1,
maxLevel: game.questLevels.length - 1,
startOver: function() {
...
this.currentLevel = -1;
},
nextLevel: function() {
this.currentLevel+=1;
if (this.currentLevel>= this.maxLevel) this.currentLevel =
this.maxLevel;
game.gameScene.updateLevelInfo(this.currentLevel+1);
// when displaying level, we start from 1 instead of 0, so +1
here.
...
},
...
}
 
Search WWH ::




Custom Search