# Can't make scene invisible by using setVisible(false)

**URL:** <https://phaser.discourse.group/t/cant-make-scene-invisible-by-using-setvisible-false/11121>\
**Category:** Phaser 3\
**Created:** [January 28, 2022, 4:10am UTC](https://phaser.discourse.group/t/cant-make-scene-invisible-by-using-setvisible-false/11121 "2022-01-28T04:10:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marsx2](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Marsx2](https://phaser.discourse.group/u/Marsx2)\
**Post date:** [January 28, 2022, 4:10am UTC](https://phaser.discourse.group/t/cant-make-scene-invisible-by-using-setvisible-false/11121/1 "2022-01-28T04:10:03Z")

</div>

Hi.

I am learning Phaser 3 by playing around some examples.

I failed to make scene to invisible by using setVisible(false). When checking the isVisible status, the value is “false”, but I can still see the scene with my eyes.

What was wrong with my codes? Please help me.

```javascript
<!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8" />
    <title>Phaser 3 example</title>
    <script src="//cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.js"></script>
    <style type="text/css">
        body {
            margin: 0;
        }
    </style>
</head>
<body>

<script>

var Boot = new Phaser.Class({

    Extends: Phaser.Scene,

    initialize:

    function Boot ()
    {
        Phaser.Scene.call(this, { key: 'boot', active: true });
    },

    preload: function ()
    {
        this.load.image('atari1', 'assets/sprites/atari400.png');
        this.load.image('atari2', 'assets/sprites/atari1200xl.png');
    },

    create: function ()
    {
        this.scene.start('sceneA');  
	this.scene.launch('sceneB');

	this.scene.setVisible(false,'sceneA'); //after this, sceneA is still visible to my eyes
	this.scene.setVisible(false,'sceneB'); //after this, sceneB is still visible to my eyes 

	console.log(this.scene.isVisible('sceneA'));	// it shows the value "false"
    }
});

var SceneA = new Phaser.Class({
    Extends: Phaser.Scene,

    initialize:

    function SceneA ()
    {
        Phaser.Scene.call(this, { key: 'sceneA' });
    },

    create: function ()
    {
        var image = this.add.sprite(200, 300, 'atari1').setInteractive();

        this.input.setDraggable(image);

        image.on('dragstart', function (pointer) {

            this.setTint(0xff0000);

        });

        image.on('drag', function (pointer, dragX, dragY) {

            this.x = dragX;
            this.y = dragY;

        });

        image.on('dragend', function (pointer) {

            this.clearTint();

        });
    }

});

var SceneB = new Phaser.Class({

    Extends: Phaser.Scene,

    initialize:

    function SceneB ()
    {
        Phaser.Scene.call(this, { key: 'sceneB' });
    },

    create: function ()
    {
        var image = this.add.sprite(600, 300, 'atari2').setInteractive();

        this.input.setDraggable(image);

        image.on('dragstart', function (pointer) {

            this.setTint(0xff0000);

        });

        image.on('drag', function (pointer, dragX, dragY) {

            this.x = dragX;
            this.y = dragY;

        });

        image.on('dragend', function (pointer) {

            this.clearTint();

        });
    }

});

var config = {
    type: Phaser.AUTO,
    parent: 'phaser-example',
    width: 800,
    height: 600,
    scene: [Boot, SceneA, SceneB] 
};

var game = new Phaser.Game(config);

</script>

</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [January 28, 2022, 5:42am UTC](https://phaser.discourse.group/t/cant-make-scene-invisible-by-using-setvisible-false/11121/2 "2022-01-28T05:42:37Z")

</div>

It’s because start/launch are queued and the scene is made visible again once they occur.

You can hide them in their own `init()` methods or do

```javascript
this.scene.start('sceneA');
this.scene.get('sceneA').events.once('start', () => {
  this.scene.setVisible(false, 'sceneA');
});

```

---

<div class="post-metadata">

**Author:** ![Marsx2](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Marsx2](https://phaser.discourse.group/u/Marsx2)\
**Post date:** [January 28, 2022, 7:16am UTC](https://phaser.discourse.group/t/cant-make-scene-invisible-by-using-setvisible-false/11121/3 "2022-01-28T07:16:35Z")

</div>

Hi Samme,

Thank you for your advice. It works. 😀
