Skip to content

Commit

Permalink
Save level before proceeding to next level.
Browse files Browse the repository at this point in the history
  • Loading branch information
Casmo committed Aug 22, 2015
1 parent 1c55ef1 commit 6033d74
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/BreakOut.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ var BreakOut = {
player.element.attachedBalls = [];
player.element.attachedBalls.push(player.element.ball);
}
if (typeof this.levels[this.currentLevel] == 'undefined') {
this.currentLevel = 0;
}
var file = this.levels[this.currentLevel];
ajax(BreakOut.settings.assetDir + file, function (jsonData) {
jsonData = JSON.parse(jsonData);
Expand Down Expand Up @@ -354,13 +357,14 @@ var BreakOut = {
}
});

if (window.localStorage) {
window.localStorage.setItem('currentLevel', this.currentLevel);
}

this.currentLevel++;
if (this.currentLevel > this.levels.length) {
this.currentLevel = 0;
}
if (window.localStorage) {
var level = window.localStorage.setItem('currentLevel', this.currentLevel);
}
},
addPlayer: function (id) {
var countA = 0;
Expand Down

0 comments on commit 6033d74

Please sign in to comment.