From e28abbe935033f4c8287c99e73d3d2c584a5a638 Mon Sep 17 00:00:00 2001 From: jbphet Date: Fri, 7 Jun 2024 16:38:13 -0600 Subject: [PATCH] play grab/release sounds on group sort interactions, see https://github.com/phetsims/mean-share-and-balance/issues/190 --- js/common/MeanShareAndBalanceConstants.ts | 3 ++- js/distribute/view/DistributeScreenView.ts | 16 +++++++++++++++- js/distribute/view/NotepadCandyBarNode.ts | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/js/common/MeanShareAndBalanceConstants.ts b/js/common/MeanShareAndBalanceConstants.ts index e58492f..985c709 100644 --- a/js/common/MeanShareAndBalanceConstants.ts +++ b/js/common/MeanShareAndBalanceConstants.ts @@ -103,7 +103,8 @@ const MeanShareAndBalanceConstants = { CHART_VIEW_WIDTH: ScreenView.DEFAULT_LAYOUT_BOUNDS.width - CONTROLS_PREFERRED_WIDTH - NUMBER_LINE_LEFT_X_MARGIN - NUMBER_LINE_RIGHT_X_MARGIN, FULCRUM_DEFAULT_POSITION: 5, - FULCRUM_ICON_TRIANGLE_DIMENSIONS: { triangleHeight: 22, triangleWidth: 24 } + FULCRUM_ICON_TRIANGLE_DIMENSIONS: { triangleHeight: 22, triangleWidth: 24 }, + GRAB_RELEASE_SOUND_LEVEL: 0.25 }; meanShareAndBalance.register( 'MeanShareAndBalanceConstants', MeanShareAndBalanceConstants ); diff --git a/js/distribute/view/DistributeScreenView.ts b/js/distribute/view/DistributeScreenView.ts index 3f7e87e..ba91336 100644 --- a/js/distribute/view/DistributeScreenView.ts +++ b/js/distribute/view/DistributeScreenView.ts @@ -40,6 +40,8 @@ import ResetAllButton from '../../../../scenery-phet/js/buttons/ResetAllButton.j import soundManager from '../../../../tambo/js/soundManager.js'; import dragIndicatorHand_png from '../../../../scenery-phet/images/dragIndicatorHand_png.js'; import Snack from '../../common/model/Snack.js'; +import grabCandyBarV2_mp3 from '../../../sounds/grabCandyBarV2_mp3.js'; +import releaseCandyBarV2_mp3 from '../../../sounds/releaseCandyBarV2_mp3.js'; type SelfOptions = EmptySelfOptions; type DistributeScreenViewOptions = SelfOptions & StrictOmit; @@ -261,6 +263,16 @@ export default class DistributeScreenView extends SharingScreenView { } ); this.notepadSnackLayerNode.addChild( meanPredictionSlider ); + // Create sound players from grab and release during group sort interactions. + const grabSoundClip = new SoundClip( grabCandyBarV2_mp3, { + initialOutputLevel: MeanShareAndBalanceConstants.GRAB_RELEASE_SOUND_LEVEL + } ); + soundManager.addSoundGenerator( grabSoundClip ); + const releaseSoundClip = new SoundClip( releaseCandyBarV2_mp3, { + initialOutputLevel: MeanShareAndBalanceConstants.GRAB_RELEASE_SOUND_LEVEL + } ); + soundManager.addSoundGenerator( releaseSoundClip ); + this.groupSortInteractionView = new GroupSortInteractionView( model.groupSortInteractionModel, notepadCandyBarsHighlightNode, @@ -308,7 +320,9 @@ export default class DistributeScreenView extends SharingScreenView { // Remove the candy bar from the current plate and add it to the top of the new plate. currentPlate!.removeSnack( candyBar ); newPlate.addSnackToTop( candyBar ); - } + }, + onGrab: () => grabSoundClip.play(), + onRelease: () => releaseSoundClip.play() } ); diff --git a/js/distribute/view/NotepadCandyBarNode.ts b/js/distribute/view/NotepadCandyBarNode.ts index f0e9f78..ad235b5 100644 --- a/js/distribute/view/NotepadCandyBarNode.ts +++ b/js/distribute/view/NotepadCandyBarNode.ts @@ -87,9 +87,9 @@ export default class NotepadCandyBarNode extends InteractiveHighlighting( Node ) this.dragListener = new RichPointerDragListener( { grabSound: grabCandyBarV2_mp3, - grabSoundClipOptions: { initialOutputLevel: 0.25 }, + grabSoundClipOptions: { initialOutputLevel: MeanShareAndBalanceConstants.GRAB_RELEASE_SOUND_LEVEL }, releaseSound: releaseCandyBarV2_mp3, - releaseSoundClipOptions: { initialOutputLevel: 0.25 }, + releaseSoundClipOptions: { initialOutputLevel: MeanShareAndBalanceConstants.GRAB_RELEASE_SOUND_LEVEL }, transform: modelViewTransform, positionProperty: this.candyBar.positionProperty, offsetPosition: ( viewPoint, dragListener ) => {