Skip to content

Commit

Permalink
Fix replay
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Jul 5, 2015
1 parent e7914f9 commit cede4c7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ GameState.prototype.create = function() {
this.instantReplayTween.start();
this.instantReplayTween.pause();
this.instantReplay.alpha = 0;
this.replaying = false;
// Hide dialog initially
this.groups.dialogs.alpha = 0;

Expand Down Expand Up @@ -123,10 +124,11 @@ GameState.prototype.loadLevel = function(i) {
GameState.prototype.stopReplay = function() {
this.instantReplayTween.pause();
this.instantReplay.alpha = 0;
if (this.movesIndex < 0) {
if (!this.replaying) {
// Nothing to replay
return;
}
this.replaying = false;
// Show next level
this.loadLevel(this.levelIndex + 1);
};
Expand Down Expand Up @@ -218,6 +220,7 @@ GameState.prototype.move = function(dir) {
this.dialog.setTexts([getScoreText(this.map, levels[this.levelIndex].day)]);
this.dialog.alpha = 1;
this.movesIndex = this.moves.length - 1;
this.replaying = true;
// Save progress
var levelsCompleted =
parseInt(localStorage["DrunkenViking.levels"]);
Expand Down

0 comments on commit cede4c7

Please sign in to comment.