A Scene will now emit the new CREATE event after it has been created by the Scene Manager. If the Scene has a create method this event comes after that, so is useful to knowing when a Scene may have finished creating Game Objects, etc.

This commit is contained in:
Richard Davey 2019-02-26 11:00:20 +00:00
parent a1265a207b
commit c15734f1bc
4 changed files with 30 additions and 1 deletions

View file

@ -5,6 +5,7 @@
### New Features
* There is a new Game Config property `input.windowEvents` which is true by default. It controls if Phaser will listen for any input events on the Window. If you disable this, Phaser will stop being able to emit events like `POINTER_UP_OUTSIDE`, or be aware of anything that happens outside of the Canvas re: input.
* A Scene will now emit the new `CREATE` event after it has been created by the Scene Manager. If the Scene has a `create` method this event comes after that, so is useful to knowing when a Scene may have finished creating Game Objects, etc. (thanks @jackfreak)
### Updates

View file

@ -514,7 +514,8 @@ var SceneManager = new Class({
{
var scene = loader.scene;
// Try to unlock HTML5 sounds every time any loader completes
// TODO - Remove. This should *not* be handled here
// Try to unlock HTML5 sounds every time any loader completes
if (this.game.sound.onBlurPausedSounds)
{
this.game.sound.unlock();
@ -593,6 +594,7 @@ var SceneManager = new Class({
*
* @method Phaser.Scenes.SceneManager#create
* @private
* @fires Phaser.Scenes.Events#CREATE
* @fires Phaser.Scenes.Events#TRANSITION_INIT
* @since 3.0.0
*
@ -622,6 +624,8 @@ var SceneManager = new Class({
}
settings.status = CONST.RUNNING;
sys.events.emit(Events.CREATE, scene);
},
/**

View file

@ -0,0 +1,23 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* The Scene Create Event.
*
* This event is dispatched by a Scene after it has been created by the Scene Manager.
*
* If a Scene has a `create` method then this event is emitted _after_ that has run.
*
* If there is a transition, this event will be fired after the `TRANSITION_START` event.
*
* Listen to it from a Scene using `this.scene.events.on('create', listener)`.
*
* @event Phaser.Scenes.Events#CREATE
* @since 3.16.3
*
* @param {Phaser.Scene} scene - A reference to the Scene that emitted this event.
*/
module.exports = 'create';

View file

@ -11,6 +11,7 @@
module.exports = {
BOOT: require('./BOOT_EVENT'),
CREATE: require('./CREATE_EVENT'),
DESTROY: require('./DESTROY_EVENT'),
PAUSE: require('./PAUSE_EVENT'),
POST_UPDATE: require('./POST_UPDATE_EVENT'),