Jump to content

Differences between adding sprites to game or stage


Seinelake
 Share

Recommended Posts

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

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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...