mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Removed 'group' / 'parent' argument and forced to the State children component. You should use 'make' if you wish to add elsewhere.
This commit is contained in:
parent
f79dcd0a07
commit
8ec9061b43
10 changed files with 15 additions and 30 deletions
|
@ -12,20 +12,14 @@ var factories = {};
|
||||||
|
|
||||||
var FactoryContainer = function ()
|
var FactoryContainer = function ()
|
||||||
{
|
{
|
||||||
// console.log('FactoryContainer is alive');
|
|
||||||
|
|
||||||
this.register = function (factory)
|
this.register = function (factory)
|
||||||
{
|
{
|
||||||
if (factories.hasOwnProperty(factory.KEY))
|
if (factories.hasOwnProperty(factory.KEY))
|
||||||
{
|
{
|
||||||
// console.log('Already registered', factory.KEY);
|
|
||||||
|
|
||||||
return this.getType(factory.KEY);
|
return this.getType(factory.KEY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// console.log('registering', factory.KEY);
|
|
||||||
|
|
||||||
factories[factory.KEY] = {
|
factories[factory.KEY] = {
|
||||||
add: factory.add,
|
add: factory.add,
|
||||||
make: factory.make
|
make: factory.make
|
||||||
|
@ -46,8 +40,6 @@ var FactoryContainer = function ()
|
||||||
{
|
{
|
||||||
if (factories.hasOwnProperty(factory))
|
if (factories.hasOwnProperty(factory))
|
||||||
{
|
{
|
||||||
// console.log('Loading', factory);
|
|
||||||
|
|
||||||
dest[factory] = (isFactory) ? factories[factory].add : factories[factory].make;
|
dest[factory] = (isFactory) ? factories[factory].add : factories[factory].make;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ var DynamicBitmapTextFactory = {
|
||||||
|
|
||||||
add: function (x, y, font, text, size, align)
|
add: function (x, y, font, text, size, align)
|
||||||
{
|
{
|
||||||
return this.state.children.add(new BitmapText(this.state, x, y, font, text, size, align));
|
return this.children.add(new BitmapText(this.state, x, y, font, text, size, align));
|
||||||
},
|
},
|
||||||
|
|
||||||
make: function (x, y, font, text, size, align)
|
make: function (x, y, font, text, size, align)
|
||||||
|
|
|
@ -7,7 +7,7 @@ var BitmapTextFactory = {
|
||||||
|
|
||||||
add: function (x, y, font, text, size, align)
|
add: function (x, y, font, text, size, align)
|
||||||
{
|
{
|
||||||
return this.state.children.add(new BitmapText(this.state, x, y, font, text, size, align));
|
return this.children.add(new BitmapText(this.state, x, y, font, text, size, align));
|
||||||
},
|
},
|
||||||
|
|
||||||
make: function (x, y, font, text, size, align)
|
make: function (x, y, font, text, size, align)
|
||||||
|
|
|
@ -6,11 +6,9 @@ var BlitterFactory = {
|
||||||
|
|
||||||
KEY: 'blitter',
|
KEY: 'blitter',
|
||||||
|
|
||||||
add: function (x, y, key, frame, parent)
|
add: function (x, y, key, frame)
|
||||||
{
|
{
|
||||||
if (parent === undefined) { parent = this.state; }
|
return this.children.add(new Blitter(this.state, x, y, key, frame));
|
||||||
|
|
||||||
return parent.children.add(new Blitter(this.state, x, y, key, frame));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
make: function (x, y, key, frame)
|
make: function (x, y, key, frame)
|
||||||
|
|
|
@ -7,7 +7,7 @@ var GraphicsFactory = {
|
||||||
|
|
||||||
add: function (options)
|
add: function (options)
|
||||||
{
|
{
|
||||||
return this.state.children.add(new Graphics(this.state, options));
|
return this.children.add(new Graphics(this.state, options));
|
||||||
},
|
},
|
||||||
|
|
||||||
make: function (options)
|
make: function (options)
|
||||||
|
|
|
@ -22,11 +22,9 @@ var ImageFactory = {
|
||||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||||
* @return {Phaser.Image} The newly created Image object.
|
* @return {Phaser.Image} The newly created Image object.
|
||||||
*/
|
*/
|
||||||
add: function (x, y, key, frame, parent)
|
add: function (x, y, key, frame)
|
||||||
{
|
{
|
||||||
if (parent === undefined) { parent = this.state; }
|
return this.children.add(new Image(this.state, x, y, key, frame));
|
||||||
|
|
||||||
return parent.children.add(new Image(this.state, x, y, key, frame));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
make: function (x, y, key, frame)
|
make: function (x, y, key, frame)
|
||||||
|
|
|
@ -26,20 +26,13 @@ var SpriteFactory = {
|
||||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||||
* @return {Phaser.Sprite} The newly created Sprite object.
|
* @return {Phaser.Sprite} The newly created Sprite object.
|
||||||
*/
|
*/
|
||||||
add: function (x, y, key, frame, group)
|
add: function (x, y, key, frame)
|
||||||
{
|
{
|
||||||
if (group === undefined) { group = this.state; }
|
return this.children.add(new Sprite(this.state, x, y, key, frame));
|
||||||
|
|
||||||
// console.log('ImageFactory.add', key, x, y, frame, group);
|
|
||||||
// console.log('into State', this.state);
|
|
||||||
|
|
||||||
return group.children.add(new Sprite(this.state, x, y, key, frame));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
make: function (x, y, key, frame)
|
make: function (x, y, key, frame)
|
||||||
{
|
{
|
||||||
// console.log('ImageFactory.make', key, x, y, frame);
|
|
||||||
|
|
||||||
return new Sprite(this.state, x, y, key, frame);
|
return new Sprite(this.state, x, y, key, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ var TextFactory = {
|
||||||
|
|
||||||
add: function (x, y, text, style)
|
add: function (x, y, text, style)
|
||||||
{
|
{
|
||||||
return this.state.children.add(new Text(this.state, x, y, text, style));
|
return this.children.add(new Text(this.state, x, y, text, style));
|
||||||
},
|
},
|
||||||
|
|
||||||
make: function (x, y, text, style)
|
make: function (x, y, text, style)
|
||||||
|
|
|
@ -17,6 +17,8 @@ var GameObjectCreator = function (state)
|
||||||
{
|
{
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
|
||||||
|
this.children = state.sys.children;
|
||||||
|
|
||||||
FactoryContainer.load(this, false);
|
FactoryContainer.load(this, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ var GameObjectFactory = function (state)
|
||||||
{
|
{
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
|
||||||
|
this.children = state.sys.children;
|
||||||
|
|
||||||
FactoryContainer.load(this, true);
|
FactoryContainer.load(this, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,7 +28,7 @@ GameObjectFactory.prototype = {
|
||||||
|
|
||||||
existing: function (child)
|
existing: function (child)
|
||||||
{
|
{
|
||||||
return this.state.children.add(child);
|
return this.children.add(child);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function ()
|
destroy: function ()
|
||||||
|
|
Loading…
Reference in a new issue