I am running into an issue trying to release() an Array that I had previously retained with retain()
Basically I have an Array* member variable that contains a number of Sprite* objects that are children of some other Node.
At some point I want to destroy the array and create a new one. I was seeing that the Sprites were not being freed (destructor not called) until the program exited, basically because the parent Node still had a reference to them. So before releasing the Array I looped over each Sprite and called sprite->getParent()->removeChild(sprite, true);
But when I do that, if I try and call release() on my array, I run into an assertion failure:
“Assertion `_reference > 0’ failed.”
Do I not need to call release() on my array once the contained Sprite objects have been removed from their parent Node? I am seeing the destructors for contained Sprite objects called… I am just not clear how the reference to my array is being removed since I had called retain().
Thanks for any clarification anyone can provide