Mercurial > hg > Members > e105711
annotate webGL/src/sound.js @ 5:a730b51d59eb draft
6th:use stat.js,divide render and update,change a way of updating game.
author | e105711 <yomitan.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 04 May 2012 05:22:57 +0900 |
parents | a22ff379000f |
children | 8c25fd3f9866 |
rev | line source |
---|---|
2
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
1 var filesLoaded = 0; |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
2 var filesToLoad = 13; |
0
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 var CymbalCnt = 0; |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 var HCloseCnt = 0; |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 var HOpenCnt = 0; |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 var FtomCnt = 0; |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 var KickCnt = 0; |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 var SnareCnt = 0; |
2
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
9 |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
10 function loadSounds(){ |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
11 |
4 | 12 audioHClose = loadAudio("sound/hclose.wav"); |
13 audioHClose2 = loadAudio("sound/hclose.wav"); | |
14 audioHOpen = loadAudio("sound/hopen.wav"); | |
15 audioHOpen2 = loadAudio("sound/hopen.wav"); | |
16 audioFtom = loadAudio("sound/ftom.wav"); | |
17 audioFtom2 = loadAudio("sound/ftom.wav"); | |
18 audioCymbal = loadAudio("sound/cymbal.wav"); | |
19 audioCymbal2 = loadAudio("sound/cymbal.wav"); | |
20 audioKick = loadAudio("sound/kick.wav"); | |
21 audioKick2 = loadAudio("sound/kick.wav"); | |
22 audioSnare = loadAudio("sound/snare.wav"); | |
23 audioSnare2= loadAudio("sound/snare.wav"); | |
24 audioBGM = loadAudio("sound/BGM.wav"); | |
2
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
25 |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
26 } |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
27 |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
28 function loadAudio(filepath){ |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
29 audioVar = new Audio(); |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
30 audioVar.addEventListener('canplaythrough', isAppLoaded, false); |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
31 console.log("loading"); |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
32 audioVar.src = filepath; |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
33 return audioVar; |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
34 } |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
35 |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
36 function isAppLoaded() |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
37 { |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
38 filesLoaded++; |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
39 if (filesLoaded == filesToLoad){ |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
40 console.log("called"); |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
41 gameStart(); |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
42 } |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
43 } |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
44 |
0
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 function audioStop(audioFile){ |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 if(!audioFile.ended){ |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 audioFile.pause(); |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 audioFile.load(); |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 } |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 } |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 function audioStart(audioFile){ |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 audioFile.load(); |
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 audioFile.play(); |
1
4fd71be3fb0b
2nd,Get BGM's current time and output it to console.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
56 } |
4fd71be3fb0b
2nd,Get BGM's current time and output it to console.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
57 |
4fd71be3fb0b
2nd,Get BGM's current time and output it to console.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
58 function getBGMTime(){ |
4fd71be3fb0b
2nd,Get BGM's current time and output it to console.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
59 return audioBGM.currentTime; |
2
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
60 } |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
61 |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
62 function getLoadedCnt(){ |
55702e139f69
3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
63 return filesLoaded; |
0
9285dae61395
1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64 } |