2017-08-18 00:42:14 +00:00
|
|
|
var BlitterFactory = require('../../gameobjects/blitter/BlitterFactory');
|
|
|
|
var Class = require('../../utils/Class');
|
|
|
|
var DynamicBitmapTextFactory = require('../../gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory');
|
|
|
|
var DynamicTilemapFactory = require('../../gameobjects/tilemap/dynamic/TilemapFactory');
|
|
|
|
var GraphicsFactory = require('../../gameobjects/graphics/GraphicsFactory');
|
|
|
|
var GroupFactory = require('../../gameobjects/group/GroupFactory');
|
|
|
|
var ImageFactory = require('../../gameobjects/image/ImageFactory');
|
|
|
|
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');
|
2017-07-04 00:59:31 +00:00
|
|
|
|
2017-09-13 15:06:05 +00:00
|
|
|
var factoryDef = {
|
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;
|
|
|
|
},
|
|
|
|
|
|
|
|
boot: function ()
|
|
|
|
{
|
|
|
|
this.displayList = this.scene.sys.displayList;
|
|
|
|
this.updateList = this.scene.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-07-04 00:59:31 +00:00
|
|
|
bitmapText: function (x, y, font, text, size, align)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return this.displayList.add(StaticBitmapTextFactory(this.scene, x, y, font, text, size, align));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
dynamicBitmapText: function (x, y, font, text, size, align)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return this.displayList.add(DynamicBitmapTextFactory(this.scene, x, y, font, text, size, align));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
blitter: function (x, y, key, frame)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return this.displayList.add(BlitterFactory(this.scene, x, y, key, frame));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
graphics: function (config)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return this.displayList.add(GraphicsFactory(this.scene, config));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
2017-07-04 15:44:16 +00:00
|
|
|
group: function (displayList, config)
|
2017-07-04 00:59:31 +00:00
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return GroupFactory(this.scene, displayList, config);
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
image: function (x, y, key, frame)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return this.displayList.add(ImageFactory(this.scene, x, y, key, frame));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
sprite: function (x, y, key, frame)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
var sprite = SpriteFactory(this.scene, x, y, key, frame);
|
2017-07-04 15:44:16 +00:00
|
|
|
|
|
|
|
this.displayList.add(sprite);
|
|
|
|
this.updateList.add(sprite);
|
|
|
|
|
|
|
|
return sprite;
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
text: function (x, y, text, style)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return this.displayList.add(TextFactory(this.scene, x, y, text, style));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
tilemap: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return this.displayList.add(DynamicTilemapFactory(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
staticTilemap: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return this.displayList.add(StaticTilemapFactory(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
|
2017-07-04 15:44:16 +00:00
|
|
|
},
|
2017-07-04 00:59:31 +00:00
|
|
|
|
|
|
|
tileSprite: function (x, y, width, height, key, frame)
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return this.displayList.add(TileSpriteFactory(this.scene, x, y, width, height, key, frame));
|
2017-07-27 16:40:15 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
zone: function (x, y, width, height)
|
|
|
|
{
|
|
|
|
return this.displayList.add(ZoneFactory(this.scene, x, y, width, height));
|
2017-08-03 03:06:13 +00:00
|
|
|
},
|
|
|
|
|
2017-08-11 12:22:41 +00:00
|
|
|
tween: function (config)
|
|
|
|
{
|
|
|
|
return this.scene.sys.tweens.add(config);
|
2017-09-13 15:06:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (WEBGL_RENDERER)
|
|
|
|
{
|
|
|
|
// WebGL only Game Objects
|
|
|
|
var EffectLayerFactory = require('../../gameobjects/effectlayer/EffectLayerFactory');
|
|
|
|
var LightLayerFactory = require('../../gameobjects/lightlayer/LightLayerFactory');
|
|
|
|
var MeshFactory = require('../../gameobjects/mesh/MeshFactory');
|
|
|
|
var QuadFactory = require('../../gameobjects/quad/QuadFactory');
|
|
|
|
var RenderPassFactory = require('../../gameobjects/renderpass/RenderPassFactory');
|
|
|
|
|
|
|
|
factoryDef.effectLayer = function (x, y, width, height, effectName, fragmentShader)
|
|
|
|
{
|
|
|
|
return this.displayList.add(EffectLayerFactory(this.scene, x, y, width, height, effectName, fragmentShader));
|
|
|
|
};
|
2017-08-11 12:22:41 +00:00
|
|
|
|
2017-09-13 15:06:05 +00:00
|
|
|
factoryDef.lightLayer = function ()
|
2017-08-03 03:06:13 +00:00
|
|
|
{
|
2017-08-03 23:55:20 +00:00
|
|
|
return this.displayList.add(LightLayerFactory(this.scene));
|
2017-09-13 15:06:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
factoryDef.mesh = function (x, y, vertices, uv, key, frame)
|
|
|
|
{
|
|
|
|
return this.displayList.add(MeshFactory(this.scene, x, y, vertices, uv, key, frame));
|
|
|
|
};
|
|
|
|
|
|
|
|
factoryDef.quad = function (x, y, key, frame)
|
|
|
|
{
|
|
|
|
return this.displayList.add(QuadFactory(this.scene, x, y, key, frame));
|
|
|
|
};
|
|
|
|
|
|
|
|
factoryDef.renderPass = function (x, y, width, height, shaderName, fragmentShader)
|
|
|
|
{
|
|
|
|
return this.displayList.add(RenderPassFactory(this.scene, x, y, width, height, shaderName, fragmentShader));
|
|
|
|
};
|
|
|
|
}
|
2017-07-04 00:59:31 +00:00
|
|
|
|
2017-09-13 15:06:05 +00:00
|
|
|
var GameObjectFactory = new Class(factoryDef);
|
2017-07-04 00:59:31 +00:00
|
|
|
|
|
|
|
module.exports = GameObjectFactory;
|