Skip to content

Commit

Permalink
made the reward node be removed when it's done be shown in order to c…
Browse files Browse the repository at this point in the history
…onserve memory, see #91
  • Loading branch information
jbphet committed Jun 22, 2017
1 parent 3f250e1 commit 19100ad
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions js/game/view/EEGameLevelView.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ define( function( require ) {
self.rewardNode.visible = true;
}

// for symmetry
function hideRewardNode() {
// the reward node is removed rather then hidden in order to conserve memory
function removeRewardNode() {
if ( self.rewardNode ) {
self.rewardNode.visible = false;
background.removeChild( self.rewardNode );
self.rewardNode.dispose();
self.rewardNode = null;
}
}

Expand All @@ -202,7 +204,7 @@ define( function( require ) {
showRewardNode();
}
else {
hideRewardNode();
removeRewardNode();
}
}
} );
Expand Down Expand Up @@ -247,7 +249,7 @@ define( function( require ) {
// celebratory nodes and reset the flag in the model.
this.inViewportProperty.link( function( inViewPort, wasInViewPort ) {
if ( !inViewPort && wasInViewPort && gameModel.allLevelsCompletedProperty.get() ) {
hideRewardNode();
removeRewardNode();
self.allLevelsCompletedDialog.visible = false;
gameModel.clearAllLevelsCompleted();
}
Expand Down

0 comments on commit 19100ad

Please sign in to comment.