| 7 | soundName; |
| 8 | |
| 9 | function playSound(sound, locationOrHasLocation, volume, pitch) { |
| 10 | var location = null; |
| 11 | if (!locationOrHasLocation) return; |
| 12 | if (locationOrHasLocation.world) { |
| 13 | location = locationOrHasLocation; |
| 14 | } else { |
| 15 | locationOrHasLocation = locationOrHasLocation.location; |
| 16 | if (locationOrHasLocation && locationOrHasLocation.world) { |
| 17 | location = locationOrHasLocation; |
| 18 | } |
| 19 | } |
| 20 | if (!location) { |
| 21 | console.warn('sounds.play() needs a location'); |
| 22 | return; |
| 23 | } |
| 24 | if (typeof volume == 'undefined') volume = 1; |
| 25 | if (typeof pitch == 'undefined') pitch = 1; |
| 26 | var soundEffect = new cmSoundEffect( |
| 27 | sound, |
| 28 | location.x, |
| 29 | location.y, |
| 30 | location.z, |
| 31 | volume, |
| 32 | pitch |
| 33 | ); |
| 34 | location.world.playSound(soundEffect); |
| 35 | } |
| 36 | |
| 37 | for (; i < len; i++) { |
| 38 | sound = allSounds[i]; |