---
+++
@@ -41,13 +41,23 @@
this.addEntry('');
this.entries[2].interactive = false;
this.entries[2].shadow.visible = false;
+ this.addEntry('Restart game', function() {
+ menu.popup.setText('Do you really\nwant to restart\n' +
+ 'restart the game?');
+ menu.popup.rearrange();
+ menu.popup.setCallbacks(function() {
+ stage.restart();
+ });
+ menu.popup.resize();
+ menu.popup.visible = true;
+ });
this.addEntry('Reset statistics', function() {
menu.popup.setText('Do you really\nwant to reset\n' +
'current statistics\nand restart the\ngame?');
menu.popup.rearrange();
menu.popup.setCallbacks(function() {
stage.srs.reset();
- window.location.reload();
+ stage.restart();
});
menu.popup.resize();
menu.popup.visible = true;
---
+++
@@ -56,6 +56,7 @@
Screen.call(this, this.conf_file);
this.current_screen = SCREENS.LOADING;
+ this.pause_prev_screen = null;
this.grid = null;
this.score = 0;
this.playtime = 0;
@@ -89,11 +90,15 @@
this.init_game();
};
+Stage.prototype.restart = function() {
+ this.clearAll(this);
+ this.addChild(this.loading);
+ this.init_game();
+};
+
Stage.prototype.click = function() {
if (this.current_screen == SCREENS.GAME_OVER) {
- this.clearAll(this);
- this.addChild(this.loading);
- this.init_game();
+ this.restart();
}
};
@@ -416,6 +421,10 @@
};
Stage.prototype.setPause = function(data) {
+ if (this.current_screen == SCREENS.PAUSE) {
+ return
+ }
+ this.pause_prev_screen = this.current_screen;
this.current_screen = SCREENS.PAUSE;
this.pause_start = now;
this.pause_bg.visible = true;
@@ -426,7 +435,7 @@
};
Stage.prototype.unsetPause = function(data) {
- this.current_screen = SCREENS.GAME;
+ this.current_screen = this.pause_prev_screen;
this.start_time += now - this.pause_start;
this.playtime -= now - this.pause_start;
this.last_update = this.pause_start;
Generated with KisssPM