spinnerbox Posted April 14, 2017 Share Posted April 14, 2017 I create new game object with var game = new Phaser.Game(STAGE_WIDTH, STAGE_HEIGHT, phaser.AUTO, HTML_CONTAINER); and right after this line I call to set game.sound.mute = true/false depending on the saved value in window.localStorage. But the problem is, when I console.dir(game), it prints the structure of the Phaser game object but game.sound is still null, so I cannot set the sound to muted or unmuted at that moment. When does game.sound sub-object gets created? Link to comment Share on other sites More sharing options...
spinnerbox Posted April 14, 2017 Author Share Posted April 14, 2017 When the first Phaser.State gets created? Link to comment Share on other sites More sharing options...
snowbillr Posted April 14, 2017 Share Posted April 14, 2017 Something sounds weird here, because if you tried to set the 'mute' property on 'game.sound' when 'game.sound' is null, you'd see an error in the JavaScript console complaining about trying to do something with a null value. You should make sure that code is actually executing, and then if it's not, find the right place to put it. Link to comment Share on other sites More sharing options...
spinnerbox Posted April 14, 2017 Author Share Posted April 14, 2017 When I load my main menu screen(Phaser.State) game.sound is already initialized. So in init() of MainMenuScreen I can now set game.sound.mute = true; //false But still a good to know fact. If somebody knows when exactly it gets created, please share. snowbillr 1 Link to comment Share on other sites More sharing options...
Recommended Posts