NRJ
1
I am not been able to mute the music, in the create function I am playing the music and created a function to toggle the music.
Suppose this simple example, it is giving me an error
something like setMute(false) is not a function.
create() {
this.bgMusic=this.sound.add('bgm').setLoop(true).play();
this.bgMusic.setMute(true) ;
}
samme
2
play() returns true/false.
NRJ
3
changed the code to this and it works, isn’t it strange, why the code in first post doesn’t worked and this works?
this.bgMusic=this.sound.add('bgm');
this.bgMusic.setLoop(true);
this.bgMusic.play();
//in the toggle function
this.bgMusic.setMute(true);
samme
4
The original code was doing
this.bgMusic = true;
this.bgMusic.setMute(true);
// -> TypeError: setMute is not a function.
NRJ
5
OK, Thanks for the explanation…