2018-01-16 19:49:13 +00:00
|
|
|
var Class = require('../utils/Class');
|
|
|
|
var PluginManager = require('../plugins/PluginManager');
|
2017-07-04 00:59:31 +00:00
|
|
|
|
2017-09-14 01:27:29 +00:00
|
|
|
var GameObjectCreator = new Class({
|
2017-07-04 00:59:31 +00:00
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
function GameObjectCreator (scene)
|
2017-07-04 00:59:31 +00:00
|
|
|
{
|
2018-01-16 02:08:22 +00:00
|
|
|
// The Scene that owns this plugin
|
2017-07-14 13:30:20 +00:00
|
|
|
this.scene = scene;
|
2017-11-17 13:30:53 +00:00
|
|
|
|
2018-01-16 02:08:22 +00:00
|
|
|
this.systems = scene.sys;
|
|
|
|
|
|
|
|
this.mapping = 'make';
|
|
|
|
|
|
|
|
this.systems.events.on('boot', this.boot, this);
|
|
|
|
|
2017-11-17 13:30:53 +00:00
|
|
|
this.displayList;
|
|
|
|
this.updateList;
|
|
|
|
},
|
|
|
|
|
2018-01-16 02:08:22 +00:00
|
|
|
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);
|
|
|
|
},
|
|
|
|
|
|
|
|
shutdown: function ()
|
2017-11-17 13:30:53 +00:00
|
|
|
{
|
2018-01-16 02:08:22 +00:00
|
|
|
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
2017-09-14 01:27:29 +00:00
|
|
|
destroy: function ()
|
2017-07-04 00:59:31 +00:00
|
|
|
{
|
2017-09-14 01:27:29 +00:00
|
|
|
this.scene = null;
|
2017-11-17 13:30:53 +00:00
|
|
|
this.displayList = null;
|
|
|
|
this.updateList = null;
|
2017-09-14 01:27:29 +00:00
|
|
|
}
|
2017-07-04 00:59:31 +00:00
|
|
|
|
2017-09-14 01:27:29 +00:00
|
|
|
});
|
2017-07-04 00:59:31 +00:00
|
|
|
|
2017-09-14 01:27:29 +00:00
|
|
|
// Static method called directly by the Game Object creator functions
|
2017-07-04 00:59:31 +00:00
|
|
|
|
2017-09-14 01:27:29 +00:00
|
|
|
GameObjectCreator.register = function (type, factoryFunction)
|
|
|
|
{
|
|
|
|
if (!GameObjectCreator.prototype.hasOwnProperty(type))
|
2017-08-11 12:22:41 +00:00
|
|
|
{
|
2017-09-14 01:27:29 +00:00
|
|
|
GameObjectCreator.prototype[type] = factoryFunction;
|
2017-07-04 00:59:31 +00:00
|
|
|
}
|
2017-09-13 15:06:05 +00:00
|
|
|
};
|
|
|
|
|
2018-01-16 02:08:22 +00:00
|
|
|
PluginManager.register('make', GameObjectCreator);
|
|
|
|
|
2017-07-04 00:59:31 +00:00
|
|
|
module.exports = GameObjectCreator;
|