2017-07-04 00:59:31 +00:00
|
|
|
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 GameObjectFactory = new Class({
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
|
|
|
function GameObjectFactory (state)
|
|
|
|
{
|
|
|
|
this.state = state;
|
|
|
|
|
2017-07-04 15:44:16 +00:00
|
|
|
this.displayList = state.sys.displayList;
|
|
|
|
this.updateList = state.sys.updateList;
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
bitmapText: function (x, y, font, text, size, align)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(StaticBitmapTextFactory(this.state, x, y, font, text, size, align));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
dynamicBitmapText: function (x, y, font, text, size, align)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(DynamicBitmapTextFactory(this.state, x, y, font, text, size, align));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
blitter: function (x, y, key, frame)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(BlitterFactory(this.state, x, y, key, frame));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
effectLayer: function (x, y, width, height, effectName, fragmentShader)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(EffectLayerFactory(this.state, x, y, width, height, effectName, fragmentShader));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
graphics: function (config)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(GraphicsFactory(this.state, 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-04 15:44:16 +00:00
|
|
|
return GroupFactory(this.state, displayList, config);
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
image: function (x, y, key, frame)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(ImageFactory(this.state, x, y, key, frame));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
mesh: function (x, y, vertices, uv, key, frame)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(MeshFactory(this.state, x, y, vertices, uv, key, frame));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
quad: function (x, y, key, frame)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(QuadFactory(this.state, x, y, key, frame));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
renderPass: function (x, y, width, height, shaderName, fragmentShader)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(RenderPassFactory(this.state, x, y, width, height, shaderName, fragmentShader));
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
sprite: function (x, y, key, frame)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
var sprite = SpriteFactory(this.state, x, y, key, frame);
|
|
|
|
|
|
|
|
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-04 15:44:16 +00:00
|
|
|
return this.displayList.add(TextFactory(this.state, 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-04 15:44:16 +00:00
|
|
|
return this.displayList.add(DynamicTilemapFactory(this.state, 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-04 15:44:16 +00:00
|
|
|
return this.displayList.add(StaticTilemapFactory(this.state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
|
|
|
|
},
|
2017-07-04 00:59:31 +00:00
|
|
|
|
|
|
|
tileSprite: function (x, y, width, height, key, frame)
|
|
|
|
{
|
2017-07-04 15:44:16 +00:00
|
|
|
return this.displayList.add(TileSpriteFactory(this.state, x, y, width, height, key, frame));
|
2017-07-04 00:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = GameObjectFactory;
|