mirror of
https://github.com/photonstorm/phaser
synced 2024-12-18 17:16:03 +00:00
75 lines
1.5 KiB
JavaScript
75 lines
1.5 KiB
JavaScript
var Class = require('../utils/Class');
|
|
var PluginManager = require('../plugins/PluginManager');
|
|
|
|
var GameObjectFactory = new Class({
|
|
|
|
initialize:
|
|
|
|
function GameObjectFactory (scene)
|
|
{
|
|
// The Scene that owns this plugin
|
|
this.scene = scene;
|
|
|
|
this.systems = scene.sys;
|
|
|
|
this.mapping = 'time';
|
|
|
|
this.systems.events.on('boot', this.boot, this);
|
|
|
|
this.displayList;
|
|
this.updateList;
|
|
},
|
|
|
|
boot: function ()
|
|
{
|
|
this.systems.inject(this);
|
|
|
|
this.displayList = this.systems.displayList;
|
|
this.updateList = this.systems.updateList;
|
|
|
|
this.systems.events.on('shutdown', this.shutdown, this);
|
|
this.systems.events.on('destroy', this.destroy, this);
|
|
},
|
|
|
|
existing: function (child)
|
|
{
|
|
if (child.renderCanvas || child.renderWebGL)
|
|
{
|
|
this.displayList.add(child);
|
|
}
|
|
|
|
if (child.preUpdate)
|
|
{
|
|
this.updateList.add(child);
|
|
}
|
|
|
|
return child;
|
|
},
|
|
|
|
shutdown: function ()
|
|
{
|
|
|
|
},
|
|
|
|
destroy: function ()
|
|
{
|
|
this.scene = null;
|
|
this.displayList = null;
|
|
this.updateList = null;
|
|
}
|
|
|
|
});
|
|
|
|
// Static method called directly by the Game Object factory functions
|
|
|
|
GameObjectFactory.register = function (type, factoryFunction)
|
|
{
|
|
if (!GameObjectFactory.prototype.hasOwnProperty(type))
|
|
{
|
|
GameObjectFactory.prototype[type] = factoryFunction;
|
|
}
|
|
};
|
|
|
|
PluginManager.register('add', GameObjectFactory);
|
|
|
|
module.exports = GameObjectFactory;
|