From 558589f8512654eabdd22a67e64f223d45a18438 Mon Sep 17 00:00:00 2001 From: Rex Date: Tue, 15 Feb 2022 10:10:33 +0800 Subject: [PATCH] Add onStart parameter into scene.transition(config) It can define transition action of scenes in a single scene.transition(config) call. --- src/scene/ScenePlugin.js | 9 +++++++++ src/scene/typedefs/SceneTransitionConfig.js | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index 045d31e3a..048046994 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -334,6 +334,15 @@ var ScenePlugin = new Class({ this.manager.start(key, GetFastValue(config, 'data')); } + var onStartCallback = GetFastValue(config, 'onStart', null); + + var onStartScope = GetFastValue(config, 'onStartScope', this.scene); + + if (onStartCallback) + { + onStartCallback.call(onStartScope, this.scene, target, duration); + } + this.systems.events.emit(Events.TRANSITION_OUT, target, duration); this.systems.events.on(Events.UPDATE, this.step, this); diff --git a/src/scene/typedefs/SceneTransitionConfig.js b/src/scene/typedefs/SceneTransitionConfig.js index 0d9ca816a..5e4d8cfc5 100644 --- a/src/scene/typedefs/SceneTransitionConfig.js +++ b/src/scene/typedefs/SceneTransitionConfig.js @@ -11,5 +11,7 @@ * @property {boolean} [moveBelow] - Move the target Scene to be below this one before the transition starts. * @property {function} [onUpdate] - This callback is invoked every frame for the duration of the transition. * @property {any} [onUpdateScope] - The context in which the callback is invoked. + * @property {function} [onStart] - This callback is invoked when transition starting. + * @property {any} [onStartScope] - The context in which the callback is invoked. * @property {any} [data] - An object containing any data you wish to be passed to the target scene's init / create methods (if sleep is false) or to the target scene's wake event callback (if sleep is true). */