UNPKG

matrix-engine

Version:

basic_timeline improved, VT func setup vide html element id with name arg.- DISABLE RAYCAST DEBUG TEST [2.3.3] Fix for GUI win desktop [2.3.0] DestrucMesh solution & loading convex objs for physics BASIC, SpriteAnimation CPU/texture solution added, Improv

49 lines (43 loc) 940 B
export class MatrixSounds { constructor() { this.volume = 0.5; this.audios = {}; } createClones(c, name, path) { for(var x = 1;x < c;x++) { let a = new Audio(path); a.id = name + x; a.volume = this.volume; this.audios[name + x] = a; document.body.append(a); } } createAudio(name, path, useClones) { let a = new Audio(path); a.id = name; a.volume = this.volume; this.audios[name] = a; document.body.append(a); if(typeof useClones !== 'undefined') { this.createClones(useClones, name, path); } } play(name) { if(this.audios[name].paused == true) { return this.audios[name].play() } else { return this.tryClone(name); } } tryClone(name) { var cc = 1; try { while(this.audios[name + cc].paused == false) { cc++; } if(this.audios[name + cc]) { return this.audios[name + cc].play(); } } catch(err) {} } }