mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 13:43:26 +00:00
Refactored the GameObjectFactory so it's now populated by the GameObjects directly, avoids globbing all GOs into it
This commit is contained in:
parent
bc7ef9485c
commit
1340e6930f
20 changed files with 257 additions and 205 deletions
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue