From 7deff92153c3af0bc8055d4acd4ae06131c006cf Mon Sep 17 00:00:00 2001 From: Marla Schulz Date: Mon, 3 Jun 2024 11:03:29 -0700 Subject: [PATCH] Move soccerBallsEnabledProperty under the soccerBallNodes parent tandem, see: https://github.com/phetsims/mean-share-and-balance/issues/254 --- js/view/SoccerBallNode.ts | 2 -- js/view/SoccerSceneView.ts | 10 +++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/js/view/SoccerBallNode.ts b/js/view/SoccerBallNode.ts index 2a75e7c..4f86247 100644 --- a/js/view/SoccerBallNode.ts +++ b/js/view/SoccerBallNode.ts @@ -144,8 +144,6 @@ export default class SoccerBallNode extends SoccerObjectNode { } ); this.addLinkedElement( soccerBall ); - this.addLinkedElement( soccerBallsEnabledProperty ); - super.addDebugText( soccerBall ); } } diff --git a/js/view/SoccerSceneView.ts b/js/view/SoccerSceneView.ts index 3ae61ed..f0325a5 100644 --- a/js/view/SoccerSceneView.ts +++ b/js/view/SoccerSceneView.ts @@ -85,15 +85,23 @@ export default class SoccerSceneView { + + 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