forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScenePlugin.js
More file actions
82 lines (72 loc) · 2.11 KB
/
Copy pathScenePlugin.js
File metadata and controls
82 lines (72 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License}
*/
var BasePlugin = require('./BasePlugin');
var Class = require('../utils/Class');
/**
* @classdesc
* A Scene Level Plugin is installed into every Scene and belongs to that Scene.
* It can listen for Scene events and respond to them.
* It can map itself to a Scene property, or into the Scene Systems, or both.
*
* @class ScenePlugin
* @memberOf Phaser.Plugins
* @extends Phaser.Plugins.BasePlugin
* @constructor
* @since 3.8.0
*
* @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin.
* @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager.
*/
var ScenePlugin = new Class({
Extends: BasePlugin,
initialize:
function ScenePlugin (scene, pluginManager)
{
BasePlugin.call(this, pluginManager);
this.scene = scene;
this.systems = scene.sys;
scene.sys.events.once('boot', this.boot, this);
},
/**
* This method is called when the Scene boots. It is only ever called once.
*
* By this point the plugin properties `scene` and `systems` will have already been set.
*
* In here you can listen for Scene events and set-up whatever you need for this plugin to run.
* Here are the Scene events you can listen to:
*
* start
* ready
* preupdate
* update
* postupdate
* resize
* pause
* resume
* sleep
* wake
* transitioninit
* transitionstart
* transitioncomplete
* transitionout
* shutdown
* destroy
*
* At the very least you should offer a destroy handler for when the Scene closes down, i.e:
*
* ```javascript
* var eventEmitter = this.systems.events;
* eventEmitter.once('destroy', this.sceneDestroy, this);
* ```
*
* @method Phaser.Plugins.ScenePlugin#boot
* @since 3.8.0
*/
boot: function ()
{
}
});
module.exports = ScenePlugin;