richtaur (owner)

Revisions

gist: 214079 Download_button fork
public
Public Clone URL: git://gist.github.com/214079.git
Embed All Files: show embed
DGE.audio.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* DGE audio Object. This is how I want the API to look
*/
/*
DGE.audio = {
 
mute : function() {
},
volume : function() {
},
 
music : {
get : get,
set : set
},
sfx : {
get : get,
set : set
}
 
};
*/
 
// Global methods
DGE.audio.mute();
DGE.audio.volume(Object); // undefined = return volume; Number = set volume
 
// Setting up sound FX
var sfx = DGE.audio.sfx.set({
levelUp : 'level_up.mp3',
itemGet : 'item_get.mp3'
}); // For future release: callback (complete, error)
 
// Sound FX methods
sfx.levelUp.play();
sfx.levelUp.pause();
sfx.levelUp.stop();
sfx.levelUp.single(Boolean);
sfx.levelUp.multiple(Boolean);
 
// Retrieve sound FX
var levelUp = DGE.audio.sfx.get('levelUp');
 
// Setting up music
var music = DGE.audio.music.set({
theme : 'theme.mp3',
battle1 : 'battle1.mp3',
battle2 : 'battle2.mp3'
}); // For future release: callback (complete, error)
 
// Music methods
music.theme.loop(Boolean);
music.theme.play();
music.theme.pause();
music.theme.stop();
 
DGE.audio.music.fadeIn(Number /* ms */);
DGE.audio.music.fadeOut(Number /* ms */);
DGE.audio.music.stop();
 
// Retrieve music
var theme = DGE.audio.music.get('theme');