From d6f325a1894ac5012bc80e464ce4a768e3af6aa2 Mon Sep 17 00:00:00 2001 From: jbphet Date: Tue, 27 Nov 2018 11:21:30 -0700 Subject: [PATCH] added the sound clip for when the books come into contact, see https://github.com/phetsims/friction/issues/148 --- js/friction/view/FrictionDragHandler.js | 1 + js/friction/view/FrictionScreenView.js | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/js/friction/view/FrictionDragHandler.js b/js/friction/view/FrictionDragHandler.js index b97fee78..bb37d2f4 100644 --- a/js/friction/view/FrictionDragHandler.js +++ b/js/friction/view/FrictionDragHandler.js @@ -20,6 +20,7 @@ define( function( require ) { /** * @param {FrictionModel} model * @param {Tandem} tandem + * @param {Object} [options] * @constructor */ function FrictionDragHandler( model, tandem, options ) { diff --git a/js/friction/view/FrictionScreenView.js b/js/friction/view/FrictionScreenView.js index a18199ca..d29ff527 100644 --- a/js/friction/view/FrictionScreenView.js +++ b/js/friction/view/FrictionScreenView.js @@ -26,6 +26,7 @@ define( function( require ) { const ResetAllButton = require( 'SCENERY_PHET/buttons/ResetAllButton' ); const ResetAllSoundGenerator = require( 'TAMBO/sound-generators/ResetAllSoundGenerator' ); const ScreenView = require( 'JOIST/ScreenView' ); + const SoundClip = require( 'TAMBO/sound-generators/SoundClip' ); const soundManager = require( 'TAMBO/soundManager' ); const TemperatureDecreasingDescriber = require( 'FRICTION/friction/view/describers/TemperatureDecreasingDescriber' ); const TemperatureIncreasingDescriber = require( 'FRICTION/friction/view/describers/TemperatureIncreasingDescriber' ); @@ -35,6 +36,9 @@ define( function( require ) { const chemistryString = require( 'string!FRICTION/chemistry' ); const physicsString = require( 'string!FRICTION/physics' ); + // sounds + const bookContactSound = require( 'sound!FRICTION/contact-lower.mp3' ); + // constants const THERMOMETER_FLUID_MAIN_COLOR = 'rgb(237,28,36)'; const THERMOMETER_FLUID_HIGHLIGHT_COLOR = 'rgb(240,150,150)'; @@ -49,6 +53,7 @@ define( function( require ) { * @constructor */ function FrictionScreenView( model, tandem ) { + const self = this; ScreenView.call( this, { layoutBounds: new Bounds2( 0, 0, model.width, model.height ), @@ -68,7 +73,6 @@ define( function( require ) { let frictionSummaryNode = new FrictionScreenSummaryNode( model, THERMOMETER_MIN_TEMP, THERMOMETER_MAX_TEMP ); this.screenSummaryNode.addChild( frictionSummaryNode ); - // add physics book this.addChild( new BookNode( model, physicsString, { x: 50, @@ -142,6 +146,16 @@ define( function( require ) { initialOutputLevel: 0.7 } ) ); + // set up the sound that will be produced when the books come into contact + const bookContactSoundClip = new SoundClip( bookContactSound, { initialOutputLevel: 0.5 } ); + soundManager.addSoundGenerator( bookContactSoundClip ); + model.contactProperty.link( contact => { + if ( contact ) { + bookContactSoundClip.play(); + } + } ); + + // add a node that creates a "play area" accessible section in the PDOM let controlAreaNode = new ControlAreaNode(); this.addChild( controlAreaNode ); controlAreaNode.accessibleOrder = [ resetAllButton ]; @@ -149,7 +163,7 @@ define( function( require ) { // @private this.resetFrictionScreenView = function() { - // a11y - among other things, this will reset the grab button cueing. + // a11y - among other things, this will reset the grab button cuing. this.magnifierNode.reset(); chemistryBookNode.reset();