mirror of
https://github.com/jiojciojsioe3/a3cjroijsiojiorj.git
synced 2024-11-22 19:01:51 +08:00
Fix getting stuck at the loading screen
This commit is contained in:
parent
2adbfc1e99
commit
5a82469da5
@ -23,11 +23,11 @@ function Controller(selectedSong, songData, autoPlayEnabled){
|
||||
|
||||
this.loadUIEvents = function(){
|
||||
$("#song-selection-butt").click(function(){
|
||||
assets.sounds["don"].play();
|
||||
assets.sounds["don"].playAsset();
|
||||
_this.songSelection();
|
||||
});
|
||||
$("#restart-butt").click(function(){
|
||||
assets.sounds["don"].play();
|
||||
assets.sounds["don"].playAsset();
|
||||
_this.restartSong();
|
||||
});
|
||||
$("#continue-butt").click(function(){
|
||||
@ -48,7 +48,7 @@ function Controller(selectedSong, songData, autoPlayEnabled){
|
||||
else if(ms>=0 && !started){ //when music shall starts
|
||||
setTimeout(function(){
|
||||
assets.sounds["main-music"].volume = 0.7;
|
||||
assets.sounds["main-music"].play();
|
||||
assets.sounds["main-music"].playAsset();
|
||||
}, _songData.generalInfo.audioWait);
|
||||
started=true;
|
||||
}
|
||||
@ -84,7 +84,7 @@ function Controller(selectedSong, songData, autoPlayEnabled){
|
||||
if (score.fail == 0) {
|
||||
vp = 'fullcombo';
|
||||
setTimeout(function(){
|
||||
assets.sounds['fullcombo'].play();
|
||||
assets.sounds['fullcombo'].playAsset();
|
||||
}, 1350);
|
||||
} else if (score.hp >= 50) {
|
||||
vp = 'clear';
|
||||
@ -92,7 +92,7 @@ function Controller(selectedSong, songData, autoPlayEnabled){
|
||||
vp = 'fail';
|
||||
}
|
||||
|
||||
assets.sounds['game' + vp].play();
|
||||
assets.sounds['game' + vp].playAsset();
|
||||
|
||||
setTimeout(function(){
|
||||
var scoresheet = new Scoresheet(_this, _this.getGlobalScore());
|
||||
|
@ -230,7 +230,7 @@ function Game(controller, selectedSong, songData){
|
||||
_mainMusicPlaying=false;
|
||||
}
|
||||
else{
|
||||
assets.sounds["main-music"].play();
|
||||
assets.sounds["main-music"].playAsset();
|
||||
_mainMusicPlaying=true;
|
||||
}
|
||||
}
|
||||
@ -253,14 +253,14 @@ function Game(controller, selectedSong, songData){
|
||||
|
||||
this.togglePause = function(){
|
||||
if(!_paused){
|
||||
assets.sounds["pause"].play();
|
||||
assets.sounds["pause"].playAsset();
|
||||
_paused=true;
|
||||
_latestDate = new Date();
|
||||
_this.toggleMainMusic();
|
||||
|
||||
}
|
||||
else{
|
||||
assets.sounds["cancel"].play();
|
||||
assets.sounds["cancel"].playAsset();
|
||||
_paused=false;
|
||||
var currentDate = new Date();
|
||||
_ellapsedTimeSincePause = _ellapsedTimeSincePause + Math.abs(currentDate.getTime() - _latestDate.getTime());
|
||||
|
@ -24,16 +24,21 @@ function Loader(){
|
||||
|
||||
assets.audio.forEach(function(name){
|
||||
var id = name.substr(0, name.length-4);
|
||||
var audio = new Audio();
|
||||
audio.src = '/assets/audio/'+name;
|
||||
audio.muted = true;
|
||||
audio.load();
|
||||
audio.onloadeddata = function(){
|
||||
assets.sounds[id] = new Audio();
|
||||
assets.sounds[id].src = audio.src;
|
||||
assets.sounds[id].load();
|
||||
assets.sounds[id] = new Audio();
|
||||
assets.sounds[id].muted = true;
|
||||
assets.sounds[id].playAsset = function(){
|
||||
try{
|
||||
assets.sounds[id].muted = false;
|
||||
assets.sounds[id].play()
|
||||
}catch(e){
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
assets.sounds[id].onloadeddata = function(){
|
||||
_this.assetLoaded();
|
||||
};
|
||||
assets.sounds[id].src = '/assets/audio/'+name;
|
||||
assets.sounds[id].load();
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
|
@ -13,10 +13,11 @@ function loadSong(selectedSong, autoPlayEnabled){
|
||||
assets.sounds["bgm_songsel"].pause();
|
||||
assets.sounds["bgm_songsel"].currentTime = 0;
|
||||
|
||||
assets.sounds["start"].play();
|
||||
assets.sounds["start"].playAsset();
|
||||
$("#assets").append("<img id='music-bg' src='/songs/"+_selectedSong.folder+"/bg.png' />");
|
||||
|
||||
var audio = new Audio();
|
||||
audio.muted = true;
|
||||
audio.src = '/songs/'+_selectedSong.folder+'/main.mp3';
|
||||
audio.load();
|
||||
|
||||
@ -25,6 +26,15 @@ function loadSong(selectedSong, autoPlayEnabled){
|
||||
_this.checkIfEverythingLoaded();
|
||||
});
|
||||
|
||||
audio.playAsset = function(){
|
||||
try{
|
||||
audio.muted = false;
|
||||
audio.play()
|
||||
}catch(e){
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
|
||||
audio.onloadeddata = function(){
|
||||
_musicLoaded=true;
|
||||
assets.sounds["main-music"]=audio;
|
||||
|
@ -81,13 +81,13 @@ function Scoresheet(controller, score){
|
||||
_this.setResults();
|
||||
|
||||
$("#song-select").click(function(){
|
||||
assets.sounds["don"].play();
|
||||
assets.sounds["don"].playAsset();
|
||||
bgm.pause();
|
||||
controller.songSelection();
|
||||
});
|
||||
|
||||
$("#replay").click(function(){
|
||||
assets.sounds["don"].play();
|
||||
assets.sounds["don"].playAsset();
|
||||
bgm.pause();
|
||||
controller.restartSong();
|
||||
});
|
||||
@ -96,7 +96,7 @@ function Scoresheet(controller, score){
|
||||
|
||||
}
|
||||
|
||||
assets.sounds["results"].play();
|
||||
assets.sounds["results"].playAsset();
|
||||
|
||||
bgm = new BufferedLoop(
|
||||
{url: '/assets/audio/bgm_result.ogg', duration: 0.847},
|
||||
|
@ -51,7 +51,7 @@ function SongSelect(){
|
||||
_this.endPreview();
|
||||
assets.sounds["diffsel"].pause();
|
||||
assets.sounds["diffsel"].currentTime = 0;
|
||||
assets.sounds["don"].play();
|
||||
assets.sounds["don"].playAsset();
|
||||
|
||||
clearInterval(menuLoop);
|
||||
var difficultyElement = (e.target.className=="stars" || e.target.className=="diffname") ? e.target.parentElement : e.target;
|
||||
@ -79,14 +79,14 @@ function SongSelect(){
|
||||
if ($(".opened").length && $(".opened").attr('id') == $(this).attr('id')) {
|
||||
_this.endPreview();
|
||||
bgm.play();
|
||||
assets.sounds["cancel"].play();
|
||||
assets.sounds["cancel"].playAsset();
|
||||
$(".difficulty").hide();
|
||||
$(".opened").removeClass("opened", 300);
|
||||
|
||||
assets.sounds["diffsel"].pause();
|
||||
assets.sounds["diffsel"].currentTime = 0;
|
||||
setTimeout(function(){
|
||||
assets.sounds["song-select"].play();
|
||||
assets.sounds["song-select"].playAsset();
|
||||
}, 300);
|
||||
|
||||
$('.songsel-title').fadeOut(200, function(){
|
||||
@ -100,11 +100,11 @@ function SongSelect(){
|
||||
|
||||
if(!$('.opened').length) {
|
||||
_this.startPreview($(this).data('song-id'), $(this).data('preview'));
|
||||
assets.sounds["don"].play();
|
||||
assets.sounds["don"].playAsset();
|
||||
assets.sounds["song-select"].pause();
|
||||
assets.sounds["song-select"].currentTime = 0;
|
||||
setTimeout(function(){
|
||||
assets.sounds["diffsel"].play();
|
||||
assets.sounds["diffsel"].playAsset();
|
||||
}, 300);
|
||||
|
||||
$('.songsel-title').fadeOut(200, function(){
|
||||
@ -114,7 +114,7 @@ function SongSelect(){
|
||||
} else {
|
||||
_preview.pause();
|
||||
_this.startPreview($(this).data('song-id'), $(this).data('preview'), false);
|
||||
assets.sounds["ka"].play();
|
||||
assets.sounds["ka"].playAsset();
|
||||
}
|
||||
};
|
||||
|
||||
@ -136,7 +136,7 @@ function SongSelect(){
|
||||
bgm.play();
|
||||
|
||||
setTimeout(function(){
|
||||
assets.sounds["song-select"].play();
|
||||
assets.sounds["song-select"].playAsset();
|
||||
}, 200);
|
||||
for(var i=0; i<assets.songs.length; i++){
|
||||
|
||||
|
@ -32,7 +32,7 @@ function Titlescreen(){
|
||||
$("#screen").find("#title-screen").show();
|
||||
$(window).resize(_this.positionning);
|
||||
|
||||
assets.sounds["title"].play();
|
||||
assets.sounds["title"].playAsset();
|
||||
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ function Titlescreen(){
|
||||
assets.sounds["title"].pause();
|
||||
assets.sounds["title"].currentTime = 0;
|
||||
|
||||
assets.sounds["don"].play();
|
||||
assets.sounds["don"].playAsset();
|
||||
new SongSelect();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user