CCParticleBatchNode removechild error

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.

Viewing 5 posts - 1 through 5 (of 5 total)
Author Posts
Author Posts
January 26, 2012 at 8:16 pm #238726

FBryant
Participant
@fbryant

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];

[self updateAllAtlasIndexes];

}

*** -[CCParticleSystemQuad atlasIndex]: message sent to deallocated instance 0xa8b800

Any idea whats wrong with this line?

January 27, 2012 at 1:49 pm #363543

araker
Moderator
@araker

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)
return;

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];

}

January 27, 2012 at 11:28 pm #363544

FBryant
Participant
@fbryant

Thanks :)

February 2, 2012 at 2:15 pm #363545

araker
Moderator
@araker

Fixed in develop branch.

May 22, 2013 at 6:34 pm #363546

dac
Participant
@dac

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.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.