public void RemoveSpriteFromAtlas(CCSprite sprite) { // remove from TextureAtlas TextureAtlas.RemoveQuadAtIndex(sprite.AtlasIndex); // Cleanup sprite. It might be reused (issue #569) sprite.BatchNode = null; var uIndex = Descendants.IndexOf(sprite); if (uIndex >= 0) { // update all sprites beyond this one var count = Descendants.Count; var elements = Descendants.Elements; for (var index = uIndex; index < count; ++index) { elements[index].AtlasIndex--; } Descendants.RemoveAt(uIndex); } // remove children recursively var spriteChildren = sprite.Children; if (spriteChildren != null && spriteChildren.Count > 0) { var elements = spriteChildren.Elements; for (int i = 0, count = spriteChildren.Count; i < count; i++) { RemoveSpriteFromAtlas((CCSprite)elements[i]); } } }
public void RemoveSpriteFromAtlas(CCSprite sprite) { // remove from TextureAtlas TextureAtlas.RemoveQuadAtIndex(sprite.AtlasIndex); // Cleanup sprite. It might be reused (issue #569) sprite.BatchNode = null; int uIndex = Descendants.IndexOf(sprite); if (uIndex >= 0) { Descendants.RemoveAt(uIndex); // update all sprites beyond this one int count = Descendants.Count; CCSprite[] elements = Descendants.Elements; for (; uIndex < count; ++uIndex) { elements[uIndex].AtlasIndex--; } } // remove children recursively CCRawList <CCNode> pChildren = sprite.Children; if (pChildren != null && pChildren.Count > 0) { CCNode[] elements = pChildren.Elements; for (int i = 0, count = pChildren.Count; i < count; i++) { RemoveSpriteFromAtlas((CCSprite)elements[i]); } } }