phaser/src/scene/plugins/GameObjectFactory.js

56 lines
1 KiB
JavaScript
Raw Normal View History

var Class = require('../../utils/Class');
var GameObjectFactory = new Class({
initialize:
function GameObjectFactory (scene)
{
this.scene = scene;
this.displayList;
this.updateList;
},
boot: function (sys)
{
this.displayList = sys.displayList;
this.updateList = sys.updateList;
},
existing: function (child)
{
if (child.renderCanvas || child.renderWebGL)
{
this.displayList.add(child);
}
if (child.preUpdate)
{
this.updateList.add(child);
}
return child;
},
destroy: function ()
{
this.scene = null;
this.displayList = null;
this.updateList = null;
}
});
// Static method called directly by the Game Object factory functions
2017-08-03 03:06:13 +00:00
GameObjectFactory.register = function (type, factoryFunction)
{
if (!GameObjectFactory.prototype.hasOwnProperty(type))
{
GameObjectFactory.prototype[type] = factoryFunction;
}
};
module.exports = GameObjectFactory;