mirror of
https://github.com/photonstorm/phaser
synced 2024-11-30 08:31:01 +00:00
Children components belong to the State now and fixed parent checks so all the movement methods now work again.
This commit is contained in:
parent
2425d0138e
commit
df97aeca2f
1 changed files with 10 additions and 9 deletions
|
@ -4,9 +4,10 @@ var Children = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function Children (owner)
|
function Children (state)
|
||||||
{
|
{
|
||||||
this.owner = owner;
|
// The State that owns this component
|
||||||
|
this.state = state;
|
||||||
|
|
||||||
// The objects that belong to this collection.
|
// The objects that belong to this collection.
|
||||||
// The equivalent of the old `Sprite.children` array.
|
// The equivalent of the old `Sprite.children` array.
|
||||||
|
@ -17,7 +18,7 @@ var Children = new Class({
|
||||||
|
|
||||||
add: function (child)
|
add: function (child)
|
||||||
{
|
{
|
||||||
if (child.parent === this)
|
if (child.parent === this.state)
|
||||||
{
|
{
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +27,7 @@ var Children = new Class({
|
||||||
child.parent.children.remove(child);
|
child.parent.children.remove(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
child.parent = this.owner;
|
child.parent = this.state;
|
||||||
|
|
||||||
this.list.push(child);
|
this.list.push(child);
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ var Children = new Class({
|
||||||
child.parent.children.remove(child);
|
child.parent.children.remove(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
child.parent = this;
|
child.parent = this.state;
|
||||||
|
|
||||||
this.list.splice(index, 0, child);
|
this.list.splice(index, 0, child);
|
||||||
}
|
}
|
||||||
|
@ -322,7 +323,7 @@ var Children = new Class({
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (child.parent === this)
|
else if (child.parent === this.state)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +342,7 @@ var Children = new Class({
|
||||||
*/
|
*/
|
||||||
bringToTop: function (child)
|
bringToTop: function (child)
|
||||||
{
|
{
|
||||||
if (child.parent === this && this.getIndex(child) < this.list.length)
|
if (child.parent === this.state && this.getIndex(child) < this.list.length)
|
||||||
{
|
{
|
||||||
this.remove(child);
|
this.remove(child);
|
||||||
this.add(child);
|
this.add(child);
|
||||||
|
@ -359,7 +360,7 @@ var Children = new Class({
|
||||||
*/
|
*/
|
||||||
sendToBack: function (child)
|
sendToBack: function (child)
|
||||||
{
|
{
|
||||||
if (child.parent === this && this.getIndex(child) > 0)
|
if (child.parent === this.state && this.getIndex(child) > 0)
|
||||||
{
|
{
|
||||||
this.remove(child);
|
this.remove(child);
|
||||||
this.addAt(child, 0);
|
this.addAt(child, 0);
|
||||||
|
@ -567,7 +568,7 @@ var Children = new Class({
|
||||||
*/
|
*/
|
||||||
reparent: function (newParent)
|
reparent: function (newParent)
|
||||||
{
|
{
|
||||||
if (newParent !== this)
|
if (newParent !== this.state)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < this.list.length; i++)
|
for (var i = 0; i < this.list.length; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue