Commit 22e0f85d authored by Terence Martin's avatar Terence Martin

Add a "Just in case" check

Just to ensure that nothing goes away, before we hide a ball while
swapping we first remove it from the maze. This makes sure that the
update loop can't hose it out from under us.

I'm pretty sure this can't actually happen but I'm not 100% sure in
what sequence the code runs if it is responding to input, so bette
safe than sorry.
parent 07e0ff3f
......@@ -579,8 +579,14 @@ var nurdz;
// in the maze contents.
for (var ballIndex = 0; ballIndex < ballArray.length; ballIndex++) {
ballArray[ballIndex] = this.getCellAt(ballIndex + 1, 0);
if (ballArray[ballIndex] != null)
if (ballArray[ballIndex] != null) {
// Just to be save, clear the cell before we hide this ball
// so that the update loop can't whack it. Pretty sure this
// can't happen but I never want to experience this bug
// again, sooo...
this.clearCellAt(ballIndex + 1, 0);
ballArray[ballIndex].hide();
}
}
};
/**
......
......@@ -490,7 +490,14 @@ module nurdz.game
{
ballArray[ballIndex] = <Ball> this.getCellAt (ballIndex + 1, 0);
if (ballArray[ballIndex] != null)
{
// Just to be save, clear the cell before we hide this ball
// so that the update loop can't whack it. Pretty sure this
// can't happen but I never want to experience this bug
// again, sooo...
this.clearCellAt (ballIndex + 1, 0);
ballArray[ballIndex].hide ();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment