content/hifi-content/DomainContent/Scripts/clickVegCrunchPop.js
2022-02-13 22:49:05 +01:00

52 lines
1.2 KiB
JavaScript

//
// cloneActions.js
//
// Caitlyn 6/28/17
// Play a popping sound when entity is grabbed/triggered
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
(function() {
var _entityID = null;
var POP_SOUND = SoundCache.getSound('http://hifi-content.s3.amazonaws.com/DomainContent/production/audio/vegcrunch.wav');
this.preload = function(entityID) {
_entityID = entityID;
print('loaded ' + entityID);
};
function playPopSound(){
if (POP_SOUND.downloaded) {
Audio.playSound(POP_SOUND, {
position: Entities.getEntityProperties(_entityID, 'position').position,
volume: 0.2,
localOnly: false
});
}
}
// this.startFarTrigger = function(entityID, args) {
// playPopSound();
// };
this.startNearGrab = function(entityID, args) {
playPopSound();
};
this.clickReleaseOnEntity = function(entityID, mouseEvent) {
if (mouseEvent.isLeftButton) {
playPopSound();
}
};
});