Skip to content

Commit a14ce15

Browse files
committed
Fixed setActive and setVisible
1 parent 80a1ef3 commit a14ce15

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ The Loader has been given a slight overhaul to improve its performance and exten
5959
* SceneManager.moveAbove wouldn't move the Scene if it was already above the target Scene. Now it moves to be directly above the target Scene no matter where in the Scene List it is.
6060
* SceneManager.moveBelow wouldn't move the Scene if it was already below the target Scene. Now it moves to be directly below the target Scene no matter where in the Scene List it is.
6161
* Emitter.setEmitZone was rejecting custom objects passed as the source argument because it was checking for the wrong methods (thanks @samme)
62+
* ScenePlugin.setActive would only toggle the current Scene, not any given Scene.
63+
* ScenePlugin.setVisible would only toggle the current Scene, not any given Scene.
6264

6365
### Examples, Documentation and TypeScript
6466

src/scene/ScenePlugin.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,21 @@ var ScenePlugin = new Class({
626626
* @method Phaser.Scenes.ScenePlugin#setActive
627627
* @since 3.0.0
628628
*
629-
* @param {boolean} value - The Scene to set the active state for.
629+
* @param {boolean} value - The active value.
630+
* @param {string} [key] - The Scene to set the active state for.
630631
*
631632
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
632633
*/
633-
setActive: function (value)
634+
setActive: function (value, key)
634635
{
635-
this.settings.active = value;
636+
if (key === undefined) { key = this.key; }
637+
638+
var scene = this.manager.getScene(key);
639+
640+
if (scene)
641+
{
642+
scene.sys.setActive(value);
643+
}
636644

637645
return this;
638646
},
@@ -643,13 +651,21 @@ var ScenePlugin = new Class({
643651
* @method Phaser.Scenes.ScenePlugin#setVisible
644652
* @since 3.0.0
645653
*
646-
* @param {boolean} value - The Scene to set the visible state for.
654+
* @param {boolean} value - The visible value.
655+
* @param {string} [key] - The Scene to set the visible state for.
647656
*
648657
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
649658
*/
650-
setVisible: function (value)
659+
setVisible: function (value, key)
651660
{
652-
this.settings.visible = value;
661+
if (key === undefined) { key = this.key; }
662+
663+
var scene = this.manager.getScene(key);
664+
665+
if (scene)
666+
{
667+
scene.sys.setVisible(value);
668+
}
653669

654670
return this;
655671
},

0 commit comments

Comments
 (0)