Skip to content

Commit

Permalink
keep old challenge set's out of state by disposing them, #156
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 23, 2017
1 parent 54055d7 commit 55983a7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions js/game/model/BAAGameModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ define( function( require ) {
this.levelProperty.set( ShredConstants.MAP_LEVEL_NAME_TO_NUMBER( levelName ) );
this.challengeIndexProperty.set( 0 );

// (phet-io) Dispose old challenges before setting the property again.
if ( this.challengeSetProperty.get().length > 0 ) {
this.challengeSetProperty.get().forEach( function( challenge ) { challenge.dispose();} );
}

// Use the predetermined challenges (if specified by phet-io) or genearte a random challenge for the given level
var challengeSet = this.predeterminedChallenges[ this.levelProperty.get() ] || ChallengeSetFactory.generate(
this.levelProperty.get(),
Expand Down

0 comments on commit 55983a7

Please sign in to comment.