mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
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:
parent
a1265a207b
commit
c15734f1bc
4 changed files with 30 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
23
src/scene/events/CREATE_EVENT.js
Normal file
23
src/scene/events/CREATE_EVENT.js
Normal 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';
|
|
@ -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'),
|
||||
|
|
Loading…
Add table
Reference in a new issue