2017-11-09 04:01:13 +00:00
|
|
|
var ArcadeImage = require('./ArcadeImage');
|
|
|
|
var ArcadeSprite = require('./ArcadeSprite');
|
2017-11-08 17:18:41 +00:00
|
|
|
var Class = require('../../utils/Class');
|
2017-11-09 04:01:13 +00:00
|
|
|
var PhysicsGroup = require('./PhysicsGroup');
|
2017-11-09 15:32:08 +00:00
|
|
|
var CONST = require('./const');
|
2017-11-08 17:18:41 +00:00
|
|
|
|
|
|
|
var Factory = new Class({
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
|
|
|
function Factory (world)
|
|
|
|
{
|
|
|
|
this.world = world;
|
|
|
|
|
2017-11-09 04:01:13 +00:00
|
|
|
this.scene = world.scene;
|
|
|
|
|
2017-11-08 17:18:41 +00:00
|
|
|
this.sys = world.scene.sys;
|
|
|
|
},
|
|
|
|
|
2017-11-09 15:32:08 +00:00
|
|
|
staticImage: function (x, y, key, frame)
|
|
|
|
{
|
|
|
|
var image = new ArcadeImage(this.scene, CONST.STATIC_BODY, x, y, key, frame);
|
|
|
|
|
|
|
|
this.sys.displayList.add(image);
|
|
|
|
|
|
|
|
return image;
|
|
|
|
},
|
|
|
|
|
2017-11-08 17:18:41 +00:00
|
|
|
image: function (x, y, key, frame)
|
|
|
|
{
|
2017-11-09 15:32:08 +00:00
|
|
|
var image = new ArcadeImage(this.scene, CONST.DYNAMIC_BODY, x, y, key, frame);
|
2017-11-08 17:18:41 +00:00
|
|
|
|
|
|
|
this.sys.displayList.add(image);
|
|
|
|
|
|
|
|
return image;
|
|
|
|
},
|
|
|
|
|
2017-11-09 15:32:08 +00:00
|
|
|
staticSprite: function (x, y, key, frame)
|
|
|
|
{
|
|
|
|
var sprite = new ArcadeSprite(this.scene, CONST.STATIC_BODY, x, y, key, frame);
|
|
|
|
|
|
|
|
this.sys.displayList.add(sprite);
|
|
|
|
this.sys.updateList.add(sprite);
|
|
|
|
|
|
|
|
return sprite;
|
|
|
|
},
|
|
|
|
|
2017-11-08 17:18:41 +00:00
|
|
|
sprite: function (x, y, key, frame)
|
|
|
|
{
|
2017-11-09 15:32:08 +00:00
|
|
|
var sprite = new ArcadeSprite(this.scene, CONST.DYNAMIC_BODY, x, y, key, frame);
|
2017-11-08 17:18:41 +00:00
|
|
|
|
|
|
|
this.sys.displayList.add(sprite);
|
|
|
|
this.sys.updateList.add(sprite);
|
|
|
|
|
|
|
|
return sprite;
|
2017-11-09 04:01:13 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
group: function (children, config)
|
|
|
|
{
|
|
|
|
return new PhysicsGroup(this.world, this.world.scene, children, config);
|
2017-11-08 17:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = Factory;
|