Seinelake Posted February 18, 2017 Share Posted February 18, 2017 I am trying to leave the game on even if the game is out of focus with stage.disableVisibilityChange = true; However it seems to not work and I wonder if it is because my sprites aren't on the stage. I have followed tutorials that tell to add sprites into the game with game.add.sprite(x,y, 'name');. However it seems there is another way, something like stage.addChild(); if I am correct. What is the difference between these two. Should I use the second one and why? Is it the reason it is not working or something else. Currently I initialize the game and stage like this: game = new Phaser.Game(1000,600, Phaser.AUTO, 'gameCanvas', {preload: preload, create: create, update: update}, false, false); game.stage = new Phaser.Stage(game); game.stage.disableVisibilityChange = true; Link to comment Share on other sites More sharing options...
samme Posted February 19, 2017 Share Posted February 19, 2017 On 2/18/2017 at 9:12 AM, Seinelake said: game.stage = new Phaser.Stage(game); Don't do that, Phaser makes the Stage for you. Move the rest into create: game = new Phaser.Game(1000, 600, Phaser.AUTO, 'gameCanvas', {preload: preload, create: create, update: update}, false, false); function init() { game.stage.disableVisibilityChange = true; // … } You can keep using game.add.sprite. Seinelake 1 Link to comment Share on other sites More sharing options...
Seinelake Posted February 19, 2017 Author Share Posted February 19, 2017 Thank you very much. Moving the game.stage.disableVisibilityChange inside create() worked. Link to comment Share on other sites More sharing options...
Recommended Posts