Skip to content

Commit

Permalink
alternative way of triggering balloon-on-sweater sound, see #484
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Feb 22, 2021
1 parent 21d98c2 commit 76c46a4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js/balloons-and-static-electricity/view/BalloonNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,18 @@ class BalloonNode extends Node {
initialOutputLevel: 0.1
} );
soundManager.addSoundGenerator( balloonHitsSweaterSoundClip );
model.onSweaterProperty.link( onSweater => {
if ( onSweater && !model.isDraggedProperty.value ) {
model.velocityProperty.lazyLink( ( currentVelocity, previousVelocity ) => {
const currentSpeed = currentVelocity.magnitude;
const previousSpeed = previousVelocity.magnitude;
if ( currentSpeed === 0 && previousSpeed > 0 && model.onSweaterProperty.value ){
balloonHitsSweaterSoundClip.play();
}
} );
// model.onSweaterProperty.link( onSweater => {
// if ( onSweater && !model.isDraggedProperty.value ) {
// balloonHitsSweaterSoundClip.play();
// }
// } );

// sound generation for when the balloon hits the wall
const balloonHitsWallSoundClip = new SoundClip( balloonHitsWallSound, {
Expand Down

0 comments on commit 76c46a4

Please sign in to comment.