mirror of
https://github.com/photonstorm/phaser
synced 2024-12-22 11:03:23 +00:00
4ec30b8db8
Added is back in as DataManager, which Game Objects can have an instance of. Plus exposed as DataManagerPlugin available to Scenes. Removed callback based system and implemented events and fixed the destroy method.
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
var Class = require('../utils/Class');
|
|
var DataManager = require('./DataManager');
|
|
var PluginManager = require('../plugins/PluginManager');
|
|
|
|
var DataManagerPlugin = new Class({
|
|
|
|
Extends: DataManager,
|
|
|
|
initialize:
|
|
|
|
function DataManagerPlugin (scene)
|
|
{
|
|
// The Scene that owns this plugin
|
|
this.scene = scene;
|
|
|
|
this.systems = scene.sys;
|
|
|
|
if (!scene.sys.settings.isBooted)
|
|
{
|
|
scene.sys.events.once('boot', this.boot, this);
|
|
}
|
|
|
|
DataManager.call(this, this.scene, scene.sys.events);
|
|
},
|
|
|
|
boot: function ()
|
|
{
|
|
var eventEmitter = this.systems.events;
|
|
|
|
eventEmitter.on('shutdown', this.shutdownPlugin, this);
|
|
eventEmitter.on('destroy', this.destroyPlugin, this);
|
|
},
|
|
|
|
shutdownPlugin: function ()
|
|
{
|
|
// Should we reset the events?
|
|
},
|
|
|
|
destroyPlugin: function ()
|
|
{
|
|
this.destroy();
|
|
|
|
this.scene = undefined;
|
|
this.systems = undefined;
|
|
}
|
|
|
|
});
|
|
|
|
PluginManager.register('DataManagerPlugin', DataManagerPlugin, 'data');
|
|
|
|
module.exports = DataManagerPlugin;
|