BlueGit

timfa frameworkv3

Files

frameworkv3 / framework / util / audio.js

audio.js

autoformat all
timfa Tim · pushed by timfa · 4 years ago
fc3febb8 History
audio.js 852 B Download Raw
1var GameAudio =
2{
3 active: false,
4
5 init: function (collection, containingFolder)
6 {
7 console.log("GAME: Loading sounds. (Note: Only supported from online-source, will fail when executed on local files.)");
8
9 try
10 {
11 var soundColl = [];
12
13 for (var i = 0; i < collection.length; i++)
14 {
15 collection[i].preload = true;
16
17 soundColl.push(collection[i]);
18 }
19
20 if (containingFolder == null)
21 containingFolder = "";
22
23 if (containingFolder != "")
24 containingFolder += "/";
25
26 ion.sound
27 ({
28 sounds: soundColl,
29 volume: 1,
30 preload: true,
31 multiplay: true,
32 path: containingFolder
33 });
34
35 this.active = true;
36 }
37 catch (err)
38 {
39 console.log("GAME: ERROR: Sounds could not be loaded. Sound will not be available.");
40 }
41 },
42
43 play: function (name)
44 {
45 if (this.active)
46 ion.sound.play(name);
47 }
48};