Skip to content

Commit

Permalink
Fix crash when resetting play screen while using rope.
Browse files Browse the repository at this point in the history
  • Loading branch information
parasyte committed Dec 22, 2013
1 parent 1881aab commit 7d8a3c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
25 changes: 14 additions & 11 deletions public/js/objects/rope.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,20 @@ game.Rope = me.Renderable.extend({
},

"removeParts" : function () {
var exploding = this.exploding;
this.parts.forEach(function (part) {
if (exploding) {
setTimeout(function () {
part.explode();
}, Math.random() * 125);
}
else {
me.game.world.removeChild(part);
}
});
if (!game.playscreen.resetting) {
var exploding = this.exploding;
this.parts.forEach(function (part) {
if (exploding) {
setTimeout(function () {
part.explode();
}, Math.random() * 125);
}
else {
me.game.world.removeChild(part);
}
});
}
this.parts = [];
},

"adjust" : function () {
Expand Down
6 changes: 5 additions & 1 deletion public/js/screens/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ game.Overlay = me.ImageLayer.extend({

game.PlayScreen = me.ScreenObject.extend({
"onResetEvent" : function () {
game.playscreen.resetting = false;

// Music
if (!me.audio.getCurrentTrack()) {
me.audio.playTrack("city");
Expand Down Expand Up @@ -128,7 +130,7 @@ game.PlayScreen = me.ScreenObject.extend({
},

"mousedown" : function (e) {
if (me.state.isPaused()) {
if (me.state.isPaused() || game.playscreen.resetting) {
return;
}

Expand Down Expand Up @@ -174,11 +176,13 @@ game.PlayScreen = me.ScreenObject.extend({
},

"end" : function () {
game.playscreen.resetting = true;
new me.Tween(this.overlay)
.to({
"alpha" : 1
}, 500)
.onComplete(function () {
delete game.playscreen.rope;
me.state.change.defer(me.state.PLAY);
}).start();
}
Expand Down

0 comments on commit 7d8a3c3

Please sign in to comment.