Forums › Programming › cocos2d support (graphics engine) › CCParticleBatchNode removechild error
This topic contains 4 replies, has 3 voices, and was last updated by dac 11 months ago.
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?
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];
Fixed in develop branch.
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.
You must be logged in to reply to this topic.
Social Widgets powered by AB-WebLog.com.