Do I need to manually implement a cleanUp method on everything I build that extends CocosNode? I'm calling removeAllChildrenWithCleanup:YES on a Scene, but it doesn't appear to go any deeper than the Scene's immediate children and enter their cleanup methods.
removeAllChildrenWithCleanup:YES - is this recursive?
(6 posts) (2 voices)-
Posted 2 years ago #
-
when you call
removeAllChildrenCleanup:YESall it's children( and children of their children, etc...) will callcleanup.so, you don't need to override
cleanupunless you want to do something special with it.Posted 2 years ago # -
Any reason that this wouldn't unschedule something that should be removed by
removeAllChildrenCleanup:YES?Posted 2 years ago # -
if it doesn't, then, it's a bug.
have you tried with v0.8-rc2 ? Could you confirm that it still happens with v0.8-rc2 ?Posted 2 years ago # -
I haven't tried it on .8x yet - we're still on 0.7.2. We've been so close to launch on this app that upgrading Cocos hasn't been a priority yet. I'll create a branch though and give it a few runs on .8 to see what happens though.
In the meantime, I've overridden the
cleanupmethod in a few nodes as a workaround.Posted 2 years ago # -
Yes, I think the bug is present in v0.7.x, but it was fixed in v0.8-rc1.
If you want to fix it on v0.7.x, you can do this:
- Edit CocosNode.m
- EditremoveAllChildrenWithCleanup
- Make sure thatonExitis called BEFOREcleanup.eg:
-(void) removeAllChildrenWithCleanup:(BOOL)cleanup { // not using detachChild improves speed here for( CocosNode * c in children) { [c setParent: nil]; // IMPORTANT: // - 1st do onExit // -2nd cleanup if( isRunning ) [c onExit]; if( cleanup) { [c cleanup]; } } [children removeAllObjects]; }Posted 2 years ago #
Reply
You must log in to post.