fbryant at January 26th, 2012 20:16 — #1
Hi, in cocos2d 1.1 beta when I remove a child from a particle batch node it crashes at the first line of this method in CCParticleBatchNodet.m:
// remove child helper
-(void) removeChildFromAtlas:(CCParticleSystem*) pSystem cleanup:(BOOL) doCleanUp
[textureAtlas_ removeQuadsAtIndex:pSystem.atlasIndex amount:pSystem.totalParticles];
//after memove of data, empty the quads at the end of array
[textureAtlas_ fillWithEmptyQuadsFromIndex:textureAtlas_.totalQuads amount:pSystem.totalParticles];
//with no cleanup the particle system could be reused for self rendering
if (!doCleanUp) [pSystem useSelfRender];
*** -[CCParticleSystemQuad atlasIndex]: message sent to deallocated instance 0xa8b800
Any idea whats wrong with this line?
araker at January 27th, 2012 13:49 — #2
I think it's a order problem, removeChildFromAtlas should be called before removeChild. Weird that this didn't show up during testing.
Here's the altered removeChild method..
// override removeChild:
-(void)removeChild: (CCParticleSystem*) child cleanup:(BOOL) doCleanup
// explicit nil handling
if (child == nil)
NSAssert([children_ containsObject:child], @"CCParticleBatchNode doesn't contain the sprite. Can't remove it");
// cleanup before removing, do this this before removing the child
[self removeChildFromAtlas:child cleanup:doCleanup];
[super removeChild:child cleanup:doCleanup];
fbryant at January 27th, 2012 23:28 — #3
araker at February 2nd, 2012 14:15 — #4
dac at May 22nd, 2013 18:34 — #5
I just ran into this with v2, so it looks like it still exists.
CCParticleBatchNode removeChild calls [super removeChild:child cleanup:doCleanup]; and then tries to use child.