Sign in to follow this  
Seinelake

Differences between adding sprites to game or stage

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;    

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.