Skip to content

Commit

Permalink
added the sound clip for when the books come into contact, see #148
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Nov 27, 2018
1 parent 20c61fb commit d6f325a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions js/friction/view/FrictionDragHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ define( function( require ) {
/**
* @param {FrictionModel} model
* @param {Tandem} tandem
* @param {Object} [options]
* @constructor
*/
function FrictionDragHandler( model, tandem, options ) {
Expand Down
18 changes: 16 additions & 2 deletions js/friction/view/FrictionScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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)';
Expand All @@ -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 ),
Expand All @@ -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,
Expand Down Expand Up @@ -142,14 +146,24 @@ 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 ];

// @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();

Expand Down

0 comments on commit d6f325a

Please sign in to comment.