Phaser.GameObjectFactory = function (game){ this.game = game; this.world = this.game.world; } ; Phaser.GameObjectFactory.prototype = { existing: function (object){ return this.world.add(object); } , sprite: function (x, y, key, frame, group){ if (typeof group === 'undefined') { group = this.world; } return group.create(x, y, key, frame); } , child: function (group, x, y, key, frame){ return group.create(x, y, key, frame); } , tween: function (obj){ return this.game.tweens.create(obj); } , group: function (parent, name){ return new Phaser.Group(this.game, parent, name); } , 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); } , tileSprite: function (x, y, width, height, key, group){ if (typeof group === 'undefined') { group = this.world; } return group.add(new Phaser.TileSprite(this.game, x, y, width, height, key)); } , text: function (x, y, text, style, group){ if (typeof group === 'undefined') { group = this.world; } return group.add(new Phaser.Text(this.game, x, y, text, style)); } , button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group){ if (typeof group === 'undefined') { group = this.world; } return group.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame)); } , graphics: function (x, y, group){ if (typeof group === 'undefined') { group = this.world; } return group.add(new Phaser.Graphics(this.game, x, y)); } , emitter: function (x, y, maxParticles){ return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game, x, y, maxParticles)); } , bitmapText: function (x, y, text, style, group){ if (typeof group === 'undefined') { group = this.world; } return this.world.add(new Phaser.BitmapText(this.game, x, y, text, style)); } , tilemap: function (key, tilesets){ return new Phaser.Tilemap(this.game, key, tilesets); } , renderTexture: function (key, width, height){ var texture = new Phaser.RenderTexture(this.game, key, width, height); this.game.cache.addRenderTexture(key, texture); return texture; } , bitmapData: function (width, height){ return new Phaser.BitmapData(this.game, width, height); } , filter: function (filter){ var args = Array.prototype.splice.call(arguments, 1); var filter = new Phaser.Filter[filter](this.game); filter.init.apply(filter, args); return filter; } } ; Phaser.GameObjectFactory.prototype.constructor = Phaser.GameObjectFactory;