Phaser.GameObject.Factory = function (game){ this.game = game; this.world = this.game.world; } ; Phaser.GameObject.Factory.prototype.constructor = Phaser.GameObject.Factory; Phaser.GameObject.Factory.prototype = { boot: function (){ for (var gameobject in Phaser.GameObject){ if (Phaser.GameObject[gameobject].hasOwnProperty('FACTORY_KEY')) { var key = Phaser.GameObject[gameobject].FACTORY_KEY; Phaser.GameObject.Factory.prototype[key] = Phaser.GameObject[gameobject].FACTORY_ADD; } } } , existing: function (object){ return this.world.add(object); } , tween: function (object){ return this.game.tweens.create(object); } , group: function (parent, name, addToStage, enableBody, physicsBodyType){ return new Phaser.Group(this.game, parent, name, addToStage, enableBody, physicsBodyType); } , physicsGroup: function (physicsBodyType, parent, name, addToStage){ return new Phaser.Group(this.game, parent, name, addToStage, true , physicsBodyType); } , audio: function (key, volume, loop, connect){ return this.game.sound.add(key, volume, loop, connect); } , sound: function (key, volume, loop, connect){ return this.game.sound.add(key, volume, loop, connect); } , audioSprite: function (key){ return this.game.sound.addSprite(key); } , emitter: function (x, y, maxParticles){ return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game, x, y, maxParticles)); } , tilemap: function (key, tileWidth, tileHeight, width, height){ return new Phaser.Tilemap(this.game, key, tileWidth, tileHeight, width, height); } , renderTexture: function (width, height, key, addToCache){ if (key === undefined || key === '') { key = this.game.rnd.uuid(); } if (addToCache === undefined) { addToCache = false ; } var texture = new Phaser.RenderTexture(this.game, width, height, key); if (addToCache) { this.game.cache.addRenderTexture(key, texture); } return texture; } , bitmapData: function (width, height, key, addToCache){ if (addToCache === undefined) { addToCache = false ; } if (key === undefined || key === '') { key = this.game.rnd.uuid(); } var texture = new Phaser.BitmapData(this.game, key, width, height); if (addToCache) { this.game.cache.addBitmapData(key, texture); } return texture; } , filter: function (filter){ var args = Array.prototype.slice.call(arguments, 1); var filter = new Phaser.Filter[filter](this.game); filter.init.apply(filter, args); return filter; } , plugin: function (plugin){ return this.game.plugins.add(plugin); } } ;