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
140 lines (111 loc) · 4.69 KB
/
Copy pathGameObjectFactory.js
File metadata and controls
140 lines (111 loc) · 4.69 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
var Class = require('../utils/Class');
var BlitterFactory = require('../gameobjects/blitter/BlitterFactory');
var DynamicBitmapTextFactory = require('../gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory');
var DynamicTilemapFactory = require('../gameobjects/tilemap/dynamic/TilemapFactory');
var EffectLayerFactory = require('../gameobjects/effectlayer/EffectLayerFactory');
var GraphicsFactory = require('../gameobjects/graphics/GraphicsFactory');
var GroupFactory = require('../gameobjects/group/GroupFactory');
var ImageFactory = require('../gameobjects/image/ImageFactory');
var MeshFactory = require('../gameobjects/mesh/MeshFactory');
var QuadFactory = require('../gameobjects/quad/QuadFactory');
var RenderPassFactory = require('../gameobjects/renderpass/RenderPassFactory');
var SpriteFactory = require('../gameobjects/sprite/SpriteFactory');
var StaticBitmapTextFactory = require('../gameobjects/bitmaptext/static/BitmapTextFactory');
var StaticTilemapFactory = require('../gameobjects/tilemap/static/StaticTilemapFactory');
var TextFactory = require('../gameobjects/text/static/TextFactory');
var TileSpriteFactory = require('../gameobjects/tilesprite/TileSpriteFactory');
var ZoneFactory = require('../gameobjects/zone/ZoneFactory');
var LightLayerFactory = require('../gameobjects/lightlayer/LightLayerFactory');
var GameObjectFactory = new Class({
initialize:
function GameObjectFactory (scene)
{
this.scene = scene;
this.displayList = scene.sys.displayList;
this.updateList = scene.sys.updateList;
},
existing: function (child)
{
if (child.renderCanvas || child.renderWebGL)
{
this.displayList.add(child);
}
if (child.preUpdate)
{
this.updateList.add(child);
}
return child;
},
bitmapText: function (x, y, font, text, size, align)
{
return this.displayList.add(StaticBitmapTextFactory(this.scene, x, y, font, text, size, align));
},
dynamicBitmapText: function (x, y, font, text, size, align)
{
return this.displayList.add(DynamicBitmapTextFactory(this.scene, x, y, font, text, size, align));
},
blitter: function (x, y, key, frame)
{
return this.displayList.add(BlitterFactory(this.scene, x, y, key, frame));
},
effectLayer: function (x, y, width, height, effectName, fragmentShader)
{
return this.displayList.add(EffectLayerFactory(this.scene, x, y, width, height, effectName, fragmentShader));
},
graphics: function (config)
{
return this.displayList.add(GraphicsFactory(this.scene, config));
},
group: function (displayList, config)
{
return GroupFactory(this.scene, displayList, config);
},
image: function (x, y, key, frame)
{
return this.displayList.add(ImageFactory(this.scene, x, y, key, frame));
},
mesh: function (x, y, vertices, uv, key, frame)
{
return this.displayList.add(MeshFactory(this.scene, x, y, vertices, uv, key, frame));
},
quad: function (x, y, key, frame)
{
return this.displayList.add(QuadFactory(this.scene, x, y, key, frame));
},
renderPass: function (x, y, width, height, shaderName, fragmentShader)
{
return this.displayList.add(RenderPassFactory(this.scene, x, y, width, height, shaderName, fragmentShader));
},
sprite: function (x, y, key, frame)
{
var sprite = SpriteFactory(this.scene, x, y, key, frame);
this.displayList.add(sprite);
this.updateList.add(sprite);
return sprite;
},
text: function (x, y, text, style)
{
return this.displayList.add(TextFactory(this.scene, x, y, text, style));
},
tilemap: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
{
return this.displayList.add(DynamicTilemapFactory(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
},
staticTilemap: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
{
return this.displayList.add(StaticTilemapFactory(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
},
tileSprite: function (x, y, width, height, key, frame)
{
return this.displayList.add(TileSpriteFactory(this.scene, x, y, width, height, key, frame));
},
zone: function (x, y, width, height)
{
return this.displayList.add(ZoneFactory(this.scene, x, y, width, height));
},
lightLayer: function ()
{
return this.displayList.add(LightLayerFactory(this.scene));
}
});
module.exports = GameObjectFactory;