Zampano Posted November 2, 2017 Share Posted November 2, 2017 Hey there, I've encountered some weird behaviour when trying to clean up not longer used sounds. I boiled it down to this: this.sfx_loading_complete = this.sound.add("sfx_loading_complete"); console.log(this.sfx_loading_complete); this.sfx_loading_complete.destroy(); // or //game.sound.remove(this.sfx_loading_complete); console.log(this.sfx_loading_complete); Both console logs put out the fully functional sounds, regardless of whether I use remove or destroy.. What am I missing? Link to comment Share on other sites More sharing options...
samme Posted November 2, 2017 Share Posted November 2, 2017 I think that's normal. If you're using WebAudio, you should see that the context property is empty afterwards (and others as well). destroy just breaks links by nullifying references to other objects. The sounds are probably removed as well when the state is shut down, so if that's the case, you don't need to call destroy yourself. Zampano 1 Link to comment Share on other sites More sharing options...
Zampano Posted November 3, 2017 Author Share Posted November 3, 2017 Okay, you're right, the context is empty. However, the audio object is still there after changing states. Let me back up a little: I set up a system that allows the user to change volumes for sfx, music and voices independently. For that, I've got globally available arrays into which I push instances of sounds, like this: this.sfx_loading_complete = this.sound.add("sfx_loading_complete"); game.sfx_Manager.sfx_index.push(this.sfx_loading_complete); So when changing the state, I want to clear the sounds that will not be used again from memory. I'm not sure how to check if that's really the case though. Link to comment Share on other sites More sharing options...
Recommended Posts