Skip to content

Commit

Permalink
handle ?gameLevels before calling super, #108
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 9, 2022
1 parent e962140 commit 8cd1647
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions js/LevelSelectionButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,10 @@ export default class LevelSelectionButtonGroup extends Node {
const buttons: LevelSelectionButton[] = items.map( item =>
new LevelSelectionButton( new AlignBox( item.icon, alignBoxOptions ), item.scoreProperty,
combineOptions<LevelSelectionButtonOptions>( {
tandem: options.tandem.createTandem( item.tandemName! )
tandem: options.tandem.supplied ? options.tandem.createTandem( item.tandemName! ) : Tandem.OPT_OUT
}, item.options ) )
);

options.children = [ options.createLayoutNode( buttons ) ];

super( options );

// Hide buttons for levels that are not included in gameLevels.
// All buttons must be instantiated so that the PhET-iO API is not changed conditionally.
if ( options.gameLevels ) {
Expand All @@ -105,6 +101,11 @@ export default class LevelSelectionButtonGroup extends Node {
button.visible = options.gameLevels!.includes( index + 1 );
} );
}

// Create the layout for the buttons.
options.children = [ options.createLayoutNode( buttons ) ];

super( options );
}
}

Expand Down

0 comments on commit 8cd1647

Please sign in to comment.