2017-08-18 00:42:14 +00:00
|
|
|
var Class = require('../../utils/Class');
|
2017-07-04 00:59:31 +00:00
|
|
|
|
2017-09-14 00:32:10 +00:00
|
|
|
var GameObjectFactory = new Class({
|
2017-07-04 00:59:31 +00:00
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
function GameObjectFactory (scene)
|
2017-07-04 00:59:31 +00:00
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
this.scene = scene;
|
2017-07-04 00:59:31 +00:00
|
|
|
|
2017-08-15 22:37:38 +00:00
|
|
|
this.displayList;
|
|
|
|
this.updateList;
|
|
|
|
},
|
|
|
|
|
2017-09-14 00:32:10 +00:00
|
|
|
boot: function (sys)
|
2017-08-15 22:37:38 +00:00
|
|
|
{
|
2017-09-14 00:32:10 +00:00
|
|
|
this.displayList = sys.displayList;
|
|
|
|
this.updateList = sys.updateList;
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
2017-07-05 00:21:47 +00:00
|
|
|
existing: function (child)
|
|
|
|
{
|
|
|
|
if (child.renderCanvas || child.renderWebGL)
|
|
|
|
{
|
|
|
|
this.displayList.add(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (child.preUpdate)
|
|
|
|
{
|
|
|
|
this.updateList.add(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
return child;
|
|
|
|
},
|
|
|
|
|
2017-09-14 00:32:10 +00:00
|
|
|
destroy: function ()
|
2017-07-04 00:59:31 +00:00
|
|
|
{
|
2017-09-14 00:32:10 +00:00
|
|
|
this.scene = null;
|
|
|
|
this.displayList = null;
|
|
|
|
this.updateList = null;
|
|
|
|
}
|
2017-07-04 00:59:31 +00:00
|
|
|
|
2017-09-14 00:32:10 +00:00
|
|
|
});
|
2017-07-27 16:40:15 +00:00
|
|
|
|
2017-09-14 01:27:29 +00:00
|
|
|
// Static method called directly by the Game Object factory functions
|
2017-08-03 03:06:13 +00:00
|
|
|
|
2017-09-14 00:32:10 +00:00
|
|
|
GameObjectFactory.register = function (type, factoryFunction)
|
|
|
|
{
|
|
|
|
if (!GameObjectFactory.prototype.hasOwnProperty(type))
|
2017-08-11 12:22:41 +00:00
|
|
|
{
|
2017-09-14 00:32:10 +00:00
|
|
|
GameObjectFactory.prototype[type] = factoryFunction;
|
2017-09-13 15:06:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-04 00:59:31 +00:00
|
|
|
module.exports = GameObjectFactory;
|