From 352ec91bb50aa0b9b2d106a3cc2f291f4614a143 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sat, 14 Apr 2018 04:24:21 +0100 Subject: [PATCH] New methods to determine if a Scene is transitioning --- src/scene/Systems.js | 45 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/scene/Systems.js b/src/scene/Systems.js index 7266e4a44..cdd22fcf7 100644 --- a/src/scene/Systems.js +++ b/src/scene/Systems.js @@ -376,8 +376,10 @@ var Systems = new Class({ /** * Send this Scene to sleep. * - * A sleeping Scene doesn't run it's update step or render anything, but it also isn't destroyed, - * or have any of its systems or children removed, meaning it can be re-activated at any point. + * A sleeping Scene doesn't run it's update step or render anything, but it also isn't shut down + * or have any of its systems or children removed, meaning it can be re-activated at any point and + * will carry on from where it left off. It also keeps everything in memory and events and callbacks + * from other Scenes may still invoke changes within it, so be careful what is left active. * * @method Phaser.Scenes.Systems#sleep * @since 3.0.0 @@ -442,6 +444,45 @@ var Systems = new Class({ return (this.settings.status === CONST.RUNNING); }, + /** + * Is this Scene currently transitioning out to, or in from another Scene? + * + * @method Phaser.Scenes.Systems#isTransitioning + * @since 3.4.1 + * + * @return {boolean} `true` if this Scene is currently transitioning, otherwise `false`. + */ + isTransitioning: function () + { + return (this.settings.isTransition || this.scenePlugin._target !== null); + }, + + /** + * Is this Scene currently transitioning out from itself to another Scene? + * + * @method Phaser.Scenes.Systems#isTransitionOut + * @since 3.4.1 + * + * @return {boolean} `true` if this Scene is in transition to another Scene, otherwise `false`. + */ + isTransitionOut: function () + { + return (this.scenePlugin._target !== null && this.scenePlugin._duration > 0); + }, + + /** + * Is this Scene currently transitioning in from another Scene? + * + * @method Phaser.Scenes.Systems#isTransitionIn + * @since 3.4.1 + * + * @return {boolean} `true` if this Scene is transitioning in from another Scene, otherwise `false`. + */ + isTransitionIn: function () + { + return (this.settings.isTransition); + }, + /** * Is this Scene visible and rendering? *