kurtfriedrich Posted June 1, 2020 Share Posted June 1, 2020 I think if you have done these lines of code: this.load.audio('staraudio', 'assets/starAudio.mp3'); this.load.audio('jump', 'assets/jump.mp3'); then you can do: this.sound = this.sound.add('jump'); this.sound.play(); and then after a user does something a little latter this.sound = this.sound.add('staraudio'); this.sound.play(); the first one works, the second .add gets me StarsGame.js:18 Uncaught TypeError: this.sound.add is not a function i even coded a function to change sounds; changeSound = function (number) { if(number ===1){ this.sound = this.sound.add('jump'); } if(number ===2){ this.sound = this.sound.add('staraudio'); } } and I can call that from various places in my game (once) and then do a this.sound.play(); if I call it only once, using either a 1 or 2, then that sound works throughout the game, but if I try and call it a 2nd time to change the sound (or even just passing in the same int as the 1st time, I get StarsGame.js:18 Uncaught TypeError: this.sound.add is not a function It makes me think I need to call some function I can't find, like this.sound = this.sound.clear(); this.sound = this.sound.unload(); or something so that it will again allow me to pass in a sound key. thanks Link to comment Share on other sites More sharing options...
Darko Posted June 1, 2020 Share Posted June 1, 2020 Hi, looks like you are overwritting "this.sound"... try... this.sound1 = this.sound.add('jump'); this.sound1.play(); this.sound2 = this.sound.add('staraudio'); this.sound2.play(); msanatan 1 Link to comment Share on other sites More sharing options...
kurtfriedrich Posted June 1, 2020 Author Share Posted June 1, 2020 thanks a ton!! Fixed it. Link to comment Share on other sites More sharing options...
Recommended Posts