I'm trying to reparent a CocosNode. I expected the procedure to be simple:
[parent removeChild:node cleanup:YES];
[newparent addChild:node];
This fails. I get a EXC_BAD_ACCESS error, so it's clearly some sort of memory problem.
Does removeChild deallocate the node's children? The error is thrown when addChild calls the node's onEnter method and tries to cycle through its children. The same error is thrown if I do this for example:
[parent removeChild:node cleanup:YES];
NSLog(@"children count %d", [[node children] count]);
Is there a way for me to preserve the node's children safely when I remove the child? Or is my only recourse to recreate the object's children (or the object itself)?