public void InsertChild(CCSprite sprite, int uIndex) { if (TextureAtlas.TotalQuads == TextureAtlas.Capacity) { IncreaseAtlasCapacity(); } TextureAtlas.InsertQuad(ref sprite.transformedQuad, uIndex); sprite.BatchNode = this; sprite.AtlasIndex = uIndex; Descendants.Insert(uIndex, sprite); // update indices CCSprite[] delements = Descendants.Elements; for (int i = uIndex + 1, count = Descendants.Count; i < count; i++) { delements[i].AtlasIndex++; } // add children recursively CCRawList <CCNode> children = sprite.Children; if (children != null && children.Count > 0) { CCNode[] elements = children.Elements; for (int j = 0, count = children.Count; j < count; j++) { var child = (CCSprite)elements[j]; uIndex = AtlasIndexForChild(child, child.ZOrder); InsertChild(child, uIndex); } } }
protected CCSpriteBatchNode AddSpriteWithoutQuad(CCSprite child, int z, int aTag) { Debug.Assert(child != null, "Argument must be non-NULL"); // quad index is Z child.AtlasIndex = z; // XXX: optimize with a binary search int i = 0; if (Descendants.Count > 0) { CCSprite[] elements = Descendants.Elements; for (int j = 0, count = Descendants.Count; j < count; j++) { if (elements[i].AtlasIndex <= z) { ++i; } } } Descendants.Insert(i, child); base.AddChild(child, z, aTag); //#issue 1262 don't use lazy sorting, tiles are added as quads not as sprites, so sprites need to be added in order ReorderBatch(false); return(this); }
private void AddSpriteWithoutQuad(CCSprite child, int z, int aTag) { Debug.Assert(child != null, "Argument must be non-NULL"); // quad index is Z child.AtlasIndex = z; child.TextureAtlas = TextureAtlas; int i = 0; if (Descendants.Count > 0) { CCSprite[] elements = Descendants.Elements; for (int j = 0, count = Descendants.Count; j < count; j++) { if (elements[i].AtlasIndex <= z) { ++i; } } } Descendants.Insert(i, child); base.AddChild(child, z, aTag); }