forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObjectFactory.js
More file actions
75 lines (54 loc) · 1.53 KB
/
Copy pathGameObjectFactory.js
File metadata and controls
75 lines (54 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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 = 'add';
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;