Phaser.GameObjectFactory = function (game){ this.game = game; this.world = this.game.world; } ; Phaser.GameObjectFactory.prototype = { existing: function (object){ return this.world.add(object); } , image: function (x, y, key, frame, group){ if (group === undefined) { group = this.world; } return group.add(new Phaser.Image(this.game, x, y, key, frame)); } , sprite: function (x, y, key, frame, group){ if (group === undefined) { group = this.world; } return group.create(x, y, key, frame); } , creature: function (x, y, key, mesh, group){ if (group === undefined) { group = this.world; } var obj = new Phaser.Creature(this.game, x, y, key, mesh); group.add(obj); return obj; } , 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); } , spriteBatch: function (parent, name, addToStage){ if (parent === undefined) { parent = null ; } if (name === undefined) { name = 'group'; } if (addToStage === undefined) { addToStage = false ; } return new Phaser.SpriteBatch(this.game, parent, name, addToStage); } , 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); } , tileSprite: function (x, y, width, height, key, frame, group){ if (group === undefined) { group = this.world; } return group.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame)); } , rope: function (x, y, key, frame, points, group){ if (group === undefined) { group = this.world; } return group.add(new Phaser.Rope(this.game, x, y, key, frame, points)); } , text: function (x, y, text, style, group){ if (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 (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 (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)); } , retroFont: function (font, characterWidth, characterHeight, chars, charsPerRow, xSpacing, ySpacing, xOffset, yOffset){ return new Phaser.RetroFont(this.game, font, characterWidth, characterHeight, chars, charsPerRow, xSpacing, ySpacing, xOffset, yOffset); } , bitmapText: function (x, y, font, text, size, group){ if (group === undefined) { group = this.world; } return group.add(new Phaser.BitmapText(this.game, x, y, font, text, size)); } , 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; } , video: function (key, url){ return new Phaser.Video(this.game, key, url); } , 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); } } ; Phaser.GameObjectFactory.prototype.constructor = Phaser.GameObjectFactory;