In my game, I want to play music sometimes. But music that is already playing shouldn’t be overridden.
So how can I
- Check if music is playing
- Manage that sound
Ideally in an global interface like this.sound
Thanks in advance
In my game, I want to play music sometimes. But music that is already playing shouldn’t be overridden.
So how can I
Ideally in an global interface like this.sound
Thanks in advance
HTML5AudioSound has isPlaying member.
// inside scene method, create sound
const music = this.sound.add('music-name', {});
music.play();
// and later
if(music.isPlaying) {
}
See https://newdocs.phaser.io/docs/3.54.0/Phaser.Sound.HTML5AudioSound#isPlaying and https://newdocs.phaser.io/docs/3.52.0/Phaser.Sound.HTML5AudioSoundManager
(this.sound is HTML5AudioSoundManager instance)