Skip to content

Commit

Permalink
Move soccerBallsEnabledProperty under the soccerBallNodes parent tand…
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Jun 3, 2024
1 parent 6c19e30 commit 7deff92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 0 additions & 2 deletions js/view/SoccerBallNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ export default class SoccerBallNode extends SoccerObjectNode {
} );

this.addLinkedElement( soccerBall );
this.addLinkedElement( soccerBallsEnabledProperty );

super.addDebugText( soccerBall );
}
}
Expand Down
10 changes: 9 additions & 1 deletion js/view/SoccerSceneView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,23 @@ export default class SoccerSceneView<SceneModel extends SoccerSceneModel = Socce
const frontLayer = new Node();

sceneModel.soccerBalls.map( ( soccerBall, index ) => {

const soccerBallParentTandem = options.tandem.createTandem( 'soccerBallNodes' );

const soccerBallNode = new SoccerBallNode(
soccerBall,
modelViewTransform,
soccerBallsEnabledProperty, {
visibleProperty: new DerivedProperty( [ soccerBall.soccerBallPhaseProperty ], options.soccerBallDerivedVisibilityCallback ),
tandem: options.tandem.createTandem( 'soccerBallNodes' ).createTandem1Indexed( 'soccerBallNode', index ),
tandem: soccerBallParentTandem.createTandem1Indexed( 'soccerBallNode', index ),
pickable: false
} );

// We want the soccerBallsEnabledProperty to be linked under the parent tandem for all the SoccerBallNodes.
index === 0 && soccerBallNode.addLinkedElement( soccerBallsEnabledProperty, {
tandem: soccerBallParentTandem.createTandem( 'soccerBallsEnabledProperty' )
} );

backLayerSoccerBallLayer.addChild( soccerBallNode );

// While flying, it should be in front in z-order, to be in front of the accordion box
Expand Down

0 comments on commit 7deff92

Please sign in to comment.