Skip to content

Commit

Permalink
add pickup and drop sounds, add isBeingInteractedWithProperty, #9 #13
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Apr 14, 2020
1 parent 1bfe87b commit efc756a
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions js/free-objects/view/DraggableMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @author Michael Kauzmann
*/

import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import Property from '../../../../axon/js/Property.js';
import Dimension2 from '../../../../dot/js/Dimension2.js';
import Vector2 from '../../../../dot/js/Vector2.js';
Expand All @@ -13,10 +14,14 @@ import DragListener from '../../../../scenery/js/listeners/DragListener.js';
import KeyboardDragListener from '../../../../scenery/js/listeners/KeyboardDragListener.js';
import Circle from '../../../../scenery/js/nodes/Circle.js';
import Rectangle from '../../../../scenery/js/nodes/Rectangle.js';
import SoundClip from '../../../../tambo/js/sound-generators/SoundClip.js';
import soundManager from '../../../../tambo/js/soundManager.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import proportion from '../../proportion.js';
import MarkerDisplay from '../model/MarkerDisplay.js';
import Node from '../../../../scenery/js/nodes/Node.js';
import commonGrabSoundInfo from '../../../../tambo/sounds/grab_mp3.js';
import commonReleaseSoundInfo from '../../../../tambo/sounds/release_mp3.js';

class DraggableMarker extends Node {

Expand All @@ -41,6 +46,9 @@ class DraggableMarker extends Node {
focusable: true
} );

// @public (read-only)
this.isBeingInteractedWithProperty = new BooleanProperty( false );

const content = new Node();

const circle = new Circle( 20, {
Expand Down Expand Up @@ -71,16 +79,37 @@ class DraggableMarker extends Node {
this.translation = modelViewTransform.modelToViewPosition( position );
} );

const commonGrabSoundClip = new SoundClip( commonGrabSoundInfo, { initialOutput: .7 } );
const commonReleaseSoundClip = new SoundClip( commonReleaseSoundInfo, { initialOutput: .7 } );
soundManager.addSoundGenerator( commonGrabSoundClip );
soundManager.addSoundGenerator( commonReleaseSoundClip );

this.addInputListener( new DragListener( {
positionProperty: positionProperty,
transform: modelViewTransform,
dragBoundsProperty: new Property( modelViewTransform.viewToModelBounds( dragBounds ) ),
tandem: options.tandem.createTandem( 'dragListener' )
tandem: options.tandem.createTandem( 'dragListener' ),
start: () => {
commonGrabSoundClip.play();
this.isBeingInteractedWithProperty.value = true;
},
end: () => {
commonReleaseSoundClip.play();
this.isBeingInteractedWithProperty.value = false;
}
} ) );

this.addInputListener( new KeyboardDragListener( {
positionProperty: positionProperty,
transform: modelViewTransform
transform: modelViewTransform,
start: () => {
commonGrabSoundClip.play();
this.isBeingInteractedWithProperty.value = true;
},
end: () => {
commonReleaseSoundClip.play();
this.isBeingInteractedWithProperty.value = false;
}
} ) );

// TODO: cue arrows
Expand Down

0 comments on commit efc756a

Please sign in to comment.