From 8bb7d22c41a4fe5b16e62b141abcd92b7fa5cb72 Mon Sep 17 00:00:00 2001 From: denz1994 Date: Thu, 16 Jan 2020 10:02:31 -0500 Subject: [PATCH] Allow for the AllFilledNode to show again after it resets. https://github.com/phetsims/build-a-molecule/issues/135 --- js/common/model/KitCollection.js | 1 + js/common/view/BAMScreenView.js | 4 ++-- js/common/view/MoleculeCollectingScreenView.js | 14 +++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/js/common/model/KitCollection.js b/js/common/model/KitCollection.js index e945bddf..8eefc28f 100644 --- a/js/common/model/KitCollection.js +++ b/js/common/model/KitCollection.js @@ -139,6 +139,7 @@ define( require => { this.collectionBoxes.forEach( box => { box.reset(); } ); this.kits.forEach( kit => { kit.reset(); } ); this.hasBlinkedOnce = false; + this.allCollectionBoxesFilledProperty.reset(); } } diff --git a/js/common/view/BAMScreenView.js b/js/common/view/BAMScreenView.js index a0a4d69f..d125bdb2 100644 --- a/js/common/view/BAMScreenView.js +++ b/js/common/view/BAMScreenView.js @@ -153,9 +153,9 @@ define( require => { kitPanel.reset(); this.updateRefillButton(); - // If the nextCollectionButton is present on screen dispose it. + // If the nextCollectionButton is present on screen hide it. if ( this.children.includes( this.nextCollectionButton ) ) { - this.removeChild( this.nextCollectionButton ); + this.nextCollectionButton.visible = false } }, right: this.layoutBounds.right - BAMConstants.VIEW_PADDING * 1.3, diff --git a/js/common/view/MoleculeCollectingScreenView.js b/js/common/view/MoleculeCollectingScreenView.js index 13b6ee75..c1bc6eb5 100644 --- a/js/common/view/MoleculeCollectingScreenView.js +++ b/js/common/view/MoleculeCollectingScreenView.js @@ -37,6 +37,9 @@ define( require => { super( kitCollectionList ); this.kitCollectionList = kitCollectionList; + // @private + this.hasShownOnce = false; + // @private {TextPushButton} Create a next collection button this.nextCollectionButton = new TextPushButton( nextCollectionString, { centerX: this.layoutBounds.centerX - 100, @@ -110,6 +113,11 @@ define( require => { // notify attachment collectionAttachmentCallbacks.forEach( callback => { callback(); } ); + // Affects whether the AllFilledNode will show after resetting. + this.resetAllButton.addListener( () => { + this.hasShownOnce = false; + } ); + // Adjust the center of the AllFilledNode this.visibleBoundsProperty.link( () => { this.allFilledNode.center = BAMConstants.STAGE_SIZE.center; @@ -124,14 +132,14 @@ define( require => { */ addCollection( collection ) { const kitCollectionNode = BAMScreenView.prototype.addCollection.call( this, collection, true ); - let hasShownOnce = false; + this.hasShownOnce = false; // show dialog the 1st time all collection boxes are filled collection.allCollectionBoxesFilledProperty.link( filled => { if ( filled ) { - if ( !hasShownOnce ) { + if ( !this.hasShownOnce ) { this.allFilledNode.show(); - hasShownOnce = true; + this.hasShownOnce = true; } } } );