Search the Community
Showing results for tags 'play()'.
-
Hello everyone, sorry if this topic was discussed already, I couldn't find anything about it on the forum. I am relatively new to javascript and phaser, a hand would be great: I am trying to create a "music game" and I am looking for the best solution to play markers continuously from an audio file. here is part of my code: function onCreate() { console.log("onCreate") music = game.add.audio('music'); music.allowMultiple = false; music.addMarker('lvl1_1',0,1); music.addMarker('lvl1_2',1,1); music.addMarker('lvl1_3',2,1); music.addMarker('lvl1_4',3,1); music.addMarker('lvl1_5',4,1); music.addMarker('lvl1_6',5,1); music.addMarker('lvl1_7',6,1); music.addMarker('lvl1_8',7,1); music.addMarker('lvl1_9',8,1);[...]function playclicked(){ for (var i = 1; i <= maxvalue; i++){ music.play("lvl"+level.number+"_"+i); while(music.isPlaying){console.log(music.isPlaying);} } } in few words, the loop should be able to play the first marker, wait for it to complete and then play the next marker, and so on. The while loop won't get past the !music.isPlaying condition, maybe I am doing something wrong there..? The loop should also be clean enough to make the markers transition smooth, cause I am playing a song. also I am using game.load.audio(...) and not game.load.audiosprite(...) ; I previously used an audiosprite with json but I am not sure how to call out properties such isPlaying while working with it.. if someone could be so kind to explain how that works, I'd appreciate! thank you very much!!