diff --git a/v3/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js b/v3/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js index a87d8f65b..390e909c3 100644 --- a/v3/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js +++ b/v3/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js @@ -1,8 +1,15 @@ -var BitmapText = require('./DynamicBitmapText'); +var DynamicBitmapText = require('./DynamicBitmapText'); +var GameObjectFactory = require('../../../scene/plugins/GameObjectFactory'); -var DynamicBitmapTextFactory = function (scene, x, y, font, text, size) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) { - return new BitmapText(scene, x, y, font, text, size); -}; - -module.exports = DynamicBitmapTextFactory; + return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); +}); diff --git a/v3/src/gameobjects/bitmaptext/static/BitmapTextFactory.js b/v3/src/gameobjects/bitmaptext/static/BitmapTextFactory.js index 7b6e406a0..62a52d7e0 100644 --- a/v3/src/gameobjects/bitmaptext/static/BitmapTextFactory.js +++ b/v3/src/gameobjects/bitmaptext/static/BitmapTextFactory.js @@ -1,8 +1,15 @@ var BitmapText = require('./BitmapText'); +var GameObjectFactory = require('../../../scene/plugins/GameObjectFactory'); -var BitmapTextFactory = function (scene, x, y, font, text, size) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('bitmapText', function (x, y, font, text, size) { - return new BitmapText(scene, x, y, font, text, size); -}; - -module.exports = BitmapTextFactory; + return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size)); +}); diff --git a/v3/src/gameobjects/blitter/BlitterFactory.js b/v3/src/gameobjects/blitter/BlitterFactory.js index 34aae56e8..988db0ef0 100644 --- a/v3/src/gameobjects/blitter/BlitterFactory.js +++ b/v3/src/gameobjects/blitter/BlitterFactory.js @@ -1,8 +1,15 @@ var Blitter = require('./Blitter'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var BlitterFactory = function (scene, x, y, key, frame) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('blitter', function (x, y, key, frame) { - return new Blitter(scene, x, y, key, frame); -}; - -module.exports = BlitterFactory; + return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); +}); diff --git a/v3/src/gameobjects/effectlayer/EffectLayerFactory.js b/v3/src/gameobjects/effectlayer/EffectLayerFactory.js index 0ce65c736..a2d382f70 100644 --- a/v3/src/gameobjects/effectlayer/EffectLayerFactory.js +++ b/v3/src/gameobjects/effectlayer/EffectLayerFactory.js @@ -1,8 +1,18 @@ var EffectLayer = require('./EffectLayer'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var EffectLayerFactory = function (scene, x, y, width, height, effectName, fragmentShader) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +if (WEBGL_RENDERER) { - return new EffectLayer(scene, x, y, width, height, effectName, fragmentShader); -}; - -module.exports = EffectLayerFactory; + GameObjectFactory.register('effectLayer', function (x, y, width, height, effectName, fragmentShader) + { + return this.displayList.add(new EffectLayer(this.scene, x, y, width, height, effectName, fragmentShader)); + }); +} diff --git a/v3/src/gameobjects/graphics/GraphicsFactory.js b/v3/src/gameobjects/graphics/GraphicsFactory.js index 14bd425d0..528c02e0f 100644 --- a/v3/src/gameobjects/graphics/GraphicsFactory.js +++ b/v3/src/gameobjects/graphics/GraphicsFactory.js @@ -1,8 +1,15 @@ var Graphics = require('./Graphics'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var GraphicsFactory = function (scene, config) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('graphics', function (config) { - return new Graphics(scene, config); -}; - -module.exports = GraphicsFactory; + return this.displayList.add(new Graphics(this.scene, config)); +}); diff --git a/v3/src/gameobjects/group/GroupFactory.js b/v3/src/gameobjects/group/GroupFactory.js index 8720fa3e6..6dceca2ca 100644 --- a/v3/src/gameobjects/group/GroupFactory.js +++ b/v3/src/gameobjects/group/GroupFactory.js @@ -1,6 +1,15 @@ var Group = require('./Group'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var GroupFactory = function (scene, children, config) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('group', function (children, config) { if (typeof children === 'object' && config === undefined) { @@ -8,7 +17,5 @@ var GroupFactory = function (scene, children, config) children = []; } - return new Group(scene, children, config); -}; - -module.exports = GroupFactory; + return new Group(this.scene, children, config); +}); diff --git a/v3/src/gameobjects/image/ImageFactory.js b/v3/src/gameobjects/image/ImageFactory.js index df9f7bd0d..3c4cb7888 100644 --- a/v3/src/gameobjects/image/ImageFactory.js +++ b/v3/src/gameobjects/image/ImageFactory.js @@ -1,8 +1,15 @@ var Image = require('./Image'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var ImageFactory = function (scene, x, y, key, frame) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('image', function (x, y, key, frame) { - return new Image(scene, x, y, key, frame); -}; - -module.exports = ImageFactory; + return this.displayList.add(new Image(this.scene, x, y, key, frame)); +}); diff --git a/v3/src/gameobjects/lightlayer/LightLayerFactory.js b/v3/src/gameobjects/lightlayer/LightLayerFactory.js index 143eea22d..2c8375c7e 100644 --- a/v3/src/gameobjects/lightlayer/LightLayerFactory.js +++ b/v3/src/gameobjects/lightlayer/LightLayerFactory.js @@ -1,8 +1,18 @@ var LightLayer = require('./LightLayer'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var LightLayerFactory = function (scene) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +if (WEBGL_RENDERER) { - return new LightLayer(scene); -}; - -module.exports = LightLayerFactory; + GameObjectFactory.register('lightLayer', function () + { + return this.displayList.add(new LightLayer(this.scene)); + }); +} diff --git a/v3/src/gameobjects/mesh/MeshFactory.js b/v3/src/gameobjects/mesh/MeshFactory.js index 8be5a3354..93bd8792c 100644 --- a/v3/src/gameobjects/mesh/MeshFactory.js +++ b/v3/src/gameobjects/mesh/MeshFactory.js @@ -1,8 +1,18 @@ var Mesh = require('./Mesh'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var MeshFactory = function (scene, x, y, vertices, uv, key, frame) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +if (WEBGL_RENDERER) { - return new Mesh(scene, x, y, vertices, uv, key, frame); -}; - -module.exports = MeshFactory; + GameObjectFactory.register('mesh', function (x, y, vertices, uv, key, frame) + { + return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, key, frame)); + }); +} diff --git a/v3/src/gameobjects/quad/QuadFactory.js b/v3/src/gameobjects/quad/QuadFactory.js index eb9ece370..9c8aac182 100644 --- a/v3/src/gameobjects/quad/QuadFactory.js +++ b/v3/src/gameobjects/quad/QuadFactory.js @@ -1,8 +1,18 @@ var Quad = require('./Quad'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var QuadFactory = function (scene, x, y, key, frame) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +if (WEBGL_RENDERER) { - return new Quad(scene, x, y, key, frame); -}; - -module.exports = QuadFactory; + GameObjectFactory.register('quad', function (x, y, key, frame) + { + return this.displayList.add(new Quad(this.scene, x, y, key, frame)); + }); +} diff --git a/v3/src/gameobjects/renderpass/RenderPassFactory.js b/v3/src/gameobjects/renderpass/RenderPassFactory.js index dedf99003..0c6f929ca 100644 --- a/v3/src/gameobjects/renderpass/RenderPassFactory.js +++ b/v3/src/gameobjects/renderpass/RenderPassFactory.js @@ -1,8 +1,18 @@ var RenderPass = require('./RenderPass'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var RenderPassFactory = function (scene, x, y, width, height, shaderName, fragmentShader) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +if (WEBGL_RENDERER) { - return new RenderPass(scene, x, y, width, height, shaderName, fragmentShader); -}; - -module.exports = RenderPassFactory; + GameObjectFactory.register('renderPass', function (x, y, width, height, shaderName, fragmentShader) + { + return this.displayList.add(new RenderPass(this.scene, x, y, width, height, shaderName, fragmentShader)); + }); +} diff --git a/v3/src/gameobjects/sprite/SpriteFactory.js b/v3/src/gameobjects/sprite/SpriteFactory.js index 80b0fc71e..527ffab39 100644 --- a/v3/src/gameobjects/sprite/SpriteFactory.js +++ b/v3/src/gameobjects/sprite/SpriteFactory.js @@ -1,8 +1,20 @@ var Sprite = require('./Sprite'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var SpriteFactory = function (scene, x, y, key, frame) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('sprite', function (x, y, key, frame) { - return new Sprite(scene, x, y, key, frame); -}; + var sprite = new Sprite(this.scene, x, y, key, frame); -module.exports = SpriteFactory; + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); diff --git a/v3/src/gameobjects/text/static/TextFactory.js b/v3/src/gameobjects/text/static/TextFactory.js index 4ace01c2e..017066ae9 100644 --- a/v3/src/gameobjects/text/static/TextFactory.js +++ b/v3/src/gameobjects/text/static/TextFactory.js @@ -1,8 +1,15 @@ var Text = require('./Text'); +var GameObjectFactory = require('../../../scene/plugins/GameObjectFactory'); -var TextFactory = function (scene, x, y, text, style) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('text', function (x, y, text, style) { - return new Text(scene, x, y, text, style); -}; - -module.exports = TextFactory; + return this.displayList.add(new Text(this.scene, x, y, text, style)); +}); diff --git a/v3/src/gameobjects/tilemap/dynamic/TilemapFactory.js b/v3/src/gameobjects/tilemap/dynamic/TilemapFactory.js index b6eff88cf..970bf9f3e 100644 --- a/v3/src/gameobjects/tilemap/dynamic/TilemapFactory.js +++ b/v3/src/gameobjects/tilemap/dynamic/TilemapFactory.js @@ -1,9 +1,15 @@ - var Tilemap = require('./Tilemap'); +var GameObjectFactory = require('../../../scene/plugins/GameObjectFactory'); -var TilemapFactory = function (scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('tilemap', function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame) { - return new Tilemap(scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame); -}; - -module.exports = TilemapFactory; + return this.displayList.add(new Tilemap(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)); +}); diff --git a/v3/src/gameobjects/tilemap/static/StaticTilemapFactory.js b/v3/src/gameobjects/tilemap/static/StaticTilemapFactory.js index fcae7a6e4..42b2cf688 100644 --- a/v3/src/gameobjects/tilemap/static/StaticTilemapFactory.js +++ b/v3/src/gameobjects/tilemap/static/StaticTilemapFactory.js @@ -1,8 +1,15 @@ var StaticTilemap = require('./StaticTilemap'); +var GameObjectFactory = require('../../../scene/plugins/GameObjectFactory'); -var StaticTilemapFactory = function (scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('staticTilemap', function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame) { - return new StaticTilemap(scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame); -}; - -module.exports = StaticTilemapFactory; + return this.displayList.add(new StaticTilemap(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)); +}); diff --git a/v3/src/gameobjects/tilesprite/TileSpriteFactory.js b/v3/src/gameobjects/tilesprite/TileSpriteFactory.js index b7999ea5d..787bd7cec 100644 --- a/v3/src/gameobjects/tilesprite/TileSpriteFactory.js +++ b/v3/src/gameobjects/tilesprite/TileSpriteFactory.js @@ -1,8 +1,15 @@ var TileSprite = require('./TileSprite'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var TileSpriteFactory = function (scene, x, y, width, height, key, frame) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) { - return new TileSprite(scene, x, y, width, height, key, frame); -}; - -module.exports = TileSpriteFactory; + return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); +}); diff --git a/v3/src/gameobjects/zone/ZoneFactory.js b/v3/src/gameobjects/zone/ZoneFactory.js index 680d7da5f..74506c7fe 100644 --- a/v3/src/gameobjects/zone/ZoneFactory.js +++ b/v3/src/gameobjects/zone/ZoneFactory.js @@ -1,8 +1,15 @@ var Zone = require('./Zone'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); -var ZoneFactory = function (scene, x, y, width, height) +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('zone', function (x, y, width, height) { - return new Zone(scene, x, y, width, height); -}; - -module.exports = ZoneFactory; + return this.displayList.add(new Zone(this.scene, x, y, width, height)); +}); diff --git a/v3/src/scene/local/Systems.js b/v3/src/scene/local/Systems.js index 945b1b1db..7c9c0eb8d 100644 --- a/v3/src/scene/local/Systems.js +++ b/v3/src/scene/local/Systems.js @@ -93,7 +93,7 @@ var Systems = new Class({ this.updateList = new UpdateList(scene); // Sometimes the managers need access to a system created after them - this.add.boot(); + this.add.boot(this); this.inputManager.boot(); this.physicsManager.boot(); @@ -262,6 +262,7 @@ var Systems = new Class({ { // TODO + this.add.destroy(); this.pool.destroy(); this.time.destroy(); this.tweens.destroy(); diff --git a/v3/src/scene/plugins/GameObjectFactory.js b/v3/src/scene/plugins/GameObjectFactory.js index 28250a4e0..bbf273780 100644 --- a/v3/src/scene/plugins/GameObjectFactory.js +++ b/v3/src/scene/plugins/GameObjectFactory.js @@ -1,18 +1,6 @@ -var BlitterFactory = require('../../gameobjects/blitter/BlitterFactory'); var Class = require('../../utils/Class'); -var DynamicBitmapTextFactory = require('../../gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory'); -var DynamicTilemapFactory = require('../../gameobjects/tilemap/dynamic/TilemapFactory'); -var GraphicsFactory = require('../../gameobjects/graphics/GraphicsFactory'); -var GroupFactory = require('../../gameobjects/group/GroupFactory'); -var ImageFactory = require('../../gameobjects/image/ImageFactory'); -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 ZoneFactory = require('../../gameobjects/zone/ZoneFactory'); -var factoryDef = { +var GameObjectFactory = new Class({ initialize: @@ -24,10 +12,10 @@ var factoryDef = { this.updateList; }, - boot: function () + boot: function (sys) { - this.displayList = this.scene.sys.displayList; - this.updateList = this.scene.sys.updateList; + this.displayList = sys.displayList; + this.updateList = sys.updateList; }, existing: function (child) @@ -45,112 +33,23 @@ var factoryDef = { return child; }, - bitmapText: function (x, y, font, text, size, align) + destroy: function () { - return this.displayList.add(StaticBitmapTextFactory(this.scene, x, y, font, text, size, align)); - }, + this.scene = null; + this.displayList = null; + this.updateList = null; + } - dynamicBitmapText: function (x, y, font, text, size, align) +}); + +// Static method called directly by the various Game Object factory functions. + +GameObjectFactory.register = function (type, factoryFunction) +{ + if (!GameObjectFactory.prototype.hasOwnProperty(type)) { - return this.displayList.add(DynamicBitmapTextFactory(this.scene, x, y, font, text, size, align)); - }, - - blitter: function (x, y, key, frame) - { - return this.displayList.add(BlitterFactory(this.scene, x, y, key, frame)); - }, - - graphics: function (config) - { - return this.displayList.add(GraphicsFactory(this.scene, config)); - }, - - group: function (displayList, config) - { - return GroupFactory(this.scene, displayList, config); - }, - - image: function (x, y, key, frame) - { - return this.displayList.add(ImageFactory(this.scene, x, y, key, frame)); - }, - - sprite: function (x, y, key, frame) - { - var sprite = SpriteFactory(this.scene, x, y, key, frame); - - this.displayList.add(sprite); - this.updateList.add(sprite); - - return sprite; - }, - - text: function (x, y, text, style) - { - return this.displayList.add(TextFactory(this.scene, x, y, text, style)); - }, - - tilemap: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame) - { - return this.displayList.add(DynamicTilemapFactory(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)); - }, - - staticTilemap: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame) - { - return this.displayList.add(StaticTilemapFactory(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)); - }, - - tileSprite: function (x, y, width, height, key, frame) - { - return this.displayList.add(TileSpriteFactory(this.scene, x, y, width, height, key, frame)); - }, - - zone: function (x, y, width, height) - { - return this.displayList.add(ZoneFactory(this.scene, x, y, width, height)); - }, - - tween: function (config) - { - return this.scene.sys.tweens.add(config); + GameObjectFactory.prototype[type] = factoryFunction; } }; -if (WEBGL_RENDERER) -{ - // WebGL only Game Objects - var EffectLayerFactory = require('../../gameobjects/effectlayer/EffectLayerFactory'); - var LightLayerFactory = require('../../gameobjects/lightlayer/LightLayerFactory'); - var MeshFactory = require('../../gameobjects/mesh/MeshFactory'); - var QuadFactory = require('../../gameobjects/quad/QuadFactory'); - var RenderPassFactory = require('../../gameobjects/renderpass/RenderPassFactory'); - - factoryDef.effectLayer = function (x, y, width, height, effectName, fragmentShader) - { - return this.displayList.add(EffectLayerFactory(this.scene, x, y, width, height, effectName, fragmentShader)); - }; - - factoryDef.lightLayer = function () - { - return this.displayList.add(LightLayerFactory(this.scene)); - }; - - factoryDef.mesh = function (x, y, vertices, uv, key, frame) - { - return this.displayList.add(MeshFactory(this.scene, x, y, vertices, uv, key, frame)); - }; - - factoryDef.quad = function (x, y, key, frame) - { - return this.displayList.add(QuadFactory(this.scene, x, y, key, frame)); - }; - - factoryDef.renderPass = function (x, y, width, height, shaderName, fragmentShader) - { - return this.displayList.add(RenderPassFactory(this.scene, x, y, width, height, shaderName, fragmentShader)); - }; -} - -var GameObjectFactory = new Class(factoryDef); - module.exports = GameObjectFactory; diff --git a/v3/src/tween/tween/Tween.js b/v3/src/tween/tween/Tween.js index b140958c0..0666284c2 100644 --- a/v3/src/tween/tween/Tween.js +++ b/v3/src/tween/tween/Tween.js @@ -1,4 +1,5 @@ var Class = require('../../utils/Class'); +var GameObjectFactory = require('../../scene/plugins/GameObjectFactory'); var TWEEN_CONST = require('./const'); var Tween = new Class({ @@ -165,4 +166,17 @@ Tween.TYPES = [ 'onYoyo' ]; +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +GameObjectFactory.register('tween', function (config) +{ + return this.scene.sys.tweens.add(config); +}); + module.exports = Tween;