Mercurial > hg > Members > e105711
view 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 |
line wrap: on
line source
var filesLoaded = 0; var filesToLoad = 13; var CymbalCnt = 0; var HCloseCnt = 0; var HOpenCnt = 0; var FtomCnt = 0; var KickCnt = 0; var SnareCnt = 0; function loadSounds(){ audioHClose = loadAudio("sound/hclose.wav"); audioHClose2 = loadAudio("sound/hclose.wav"); audioHOpen = loadAudio("sound/hopen.wav"); audioHOpen2 = loadAudio("sound/hopen.wav"); audioFtom = loadAudio("sound/ftom.wav"); audioFtom2 = loadAudio("sound/ftom.wav"); audioCymbal = loadAudio("sound/cymbal.wav"); audioCymbal2 = loadAudio("sound/cymbal.wav"); audioKick = loadAudio("sound/kick.wav"); audioKick2 = loadAudio("sound/kick.wav"); audioSnare = loadAudio("sound/snare.wav"); audioSnare2= loadAudio("sound/snare.wav"); audioBGM = loadAudio("sound/BGM.wav"); } function loadAudio(filepath){ audioVar = new Audio(); audioVar.addEventListener('canplaythrough', isAppLoaded, false); console.log("loading"); audioVar.src = filepath; return audioVar; } function isAppLoaded() { filesLoaded++; if (filesLoaded == filesToLoad){ console.log("called"); gameStart(); } } function audioStop(audioFile){ if(!audioFile.ended){ audioFile.pause(); audioFile.load(); } } function audioStart(audioFile){ audioFile.load(); audioFile.play(); } function getBGMTime(){ return audioBGM.currentTime; } function getLoadedCnt(){ return filesLoaded; }