This commit is contained in:
Mat Groves 2013-06-29 17:47:56 +01:00
parent 4d578fe443
commit edda8b451c
18 changed files with 634 additions and 154 deletions

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

File diff suppressed because one or more lines are too long

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -823,6 +823,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -898,6 +902,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -914,7 +921,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -935,6 +941,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -954,7 +964,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -1043,8 +1052,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
@ -2477,7 +2484,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;
@ -4757,14 +4764,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -4775,16 +4793,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -4807,9 +4834,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -4819,7 +4852,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;

View file

@ -47,6 +47,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
*/ */
PIXI.DisplayObjectContainer.prototype.addChild = function(child) PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{ {
//this.addChildAt(child, this.children.length)
// return;
if(child.parent != undefined) if(child.parent != undefined)
{ {
child.parent.removeChild(child); child.parent.removeChild(child);
@ -122,6 +126,9 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
*/ */
PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
{ {
//this.addChild(child);
//console.log("AT " + index)
//return;
if(index >= 0 && index <= this.children.length) if(index >= 0 && index <= this.children.length)
{ {
if(child.parent != undefined)child.parent.removeChild(child); if(child.parent != undefined)child.parent.removeChild(child);
@ -138,7 +145,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
while(tmpChild) while(tmpChild)
} }
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first
var childLast = child.last; var childLast = child.last;
@ -159,6 +165,10 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
} }
} }
else if(index == 0)
{
previousObject = this;
}
else else
{ {
previousObject = this.children[index].last; previousObject = this.children[index].last;
@ -178,7 +188,6 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
// need to remove any render groups.. // need to remove any render groups..
if(this.__renderGroup) if(this.__renderGroup)
{ {
@ -267,8 +276,6 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
if ( index !== -1 ) if ( index !== -1 )
{ {
// unlink // // unlink //
// modify the list.. // modify the list..
var childFirst = child.first var childFirst = child.first

View file

@ -70,7 +70,7 @@ PIXI.Stage.prototype.updateTransform = function()
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
{ {
this.backgroundColor = backgroundColor || 0x000000; this.backgroundColor = backgroundColor || 0x000000;
this.backgroundColorSplit = [1,1,1,1];//HEXtoRGB(this.backgroundColor); this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
var hex = this.backgroundColor.toString(16); var hex = this.backgroundColor.toString(16);
hex = "000000".substr(0, 6 - hex.length) + hex; hex = "000000".substr(0, 6 - hex.length) + hex;
this.backgroundColorString = "#" + hex; this.backgroundColorString = "#" + hex;

View file

@ -310,14 +310,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject); if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
var safe;
/* /*
* LOOK FOR THE PREVIOUS RENDERABLE * LOOK FOR THE PREVIOUS RENDERABLE
* This part looks for the closest previous sprite that can go into a batch * This part looks for the closest previous sprite that can go into a batch
* It keeps going back until it finds a sprite or the stage * It keeps going back until it finds a sprite or the stage
*/ */
safe = 0;
var previousRenderable = displayObject.first; var previousRenderable = displayObject.first;
while(previousRenderable != this.root) while(previousRenderable != this.root)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
previousRenderable = previousRenderable._iPrev; previousRenderable = previousRenderable._iPrev;
if(previousRenderable.renderable && previousRenderable.__renderGroup)break; if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
} }
@ -328,16 +339,25 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayOb
* it keeps looking until it finds a sprite or gets to the end of the display * it keeps looking until it finds a sprite or gets to the end of the display
* scene graph * scene graph
*/ */
safe = 0
var nextRenderable = displayObject.last; var nextRenderable = displayObject.last;
while(nextRenderable._iNext) while(nextRenderable._iNext)
{ {
safe++;
if(safe > 1000)
{
console.log("BREAK")
break;
}
nextRenderable = nextRenderable._iNext; nextRenderable = nextRenderable._iNext;
if(nextRenderable.renderable && nextRenderable.__renderGroup)break; if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
} }
// one the display object hits this. we can break the loop // one the display object hits this. we can break the loop
var testObject = nextRenderable._iNext; var testObject = displayObject.last._iNext;
safe = 0;
do do
{ {
displayObject.__renderGroup = this; displayObject.__renderGroup = this;
@ -360,9 +380,15 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
// var displayObject = displayObject.first; // var displayObject = displayObject.first;
var lastObject = displayObject.last; var lastObject = displayObject.last;
var safe = 0
do do
{ {
safe++;
if(safe > 100)
{
console.log("BREAK 2s")
break;
}
displayObject.__renderGroup = null; displayObject.__renderGroup = null;
if(displayObject.renderable)this.removeObject(displayObject); if(displayObject.renderable)this.removeObject(displayObject);
displayObject = displayObject._iNext; displayObject = displayObject._iNext;
@ -372,7 +398,6 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject) PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
{ {
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
var previousSprite = previousObject; var previousSprite = previousObject;
var nextSprite = nextObject; var nextSprite = nextObject;