
cocos2d-iphone - issue #1515
CCParallaxNode incorrect implementation of -(void) removeChild:(CCNode*)node cleanup:(BOOL)cleanup
What steps will reproduce the problem? 1. Remove child in parallax node when it's out of screen
What is the expected output? What do you see instead?
What cocos2d version are you using ? V3.0
What iOS / Mac SDK are you using ?
Debug or Release ? Both
Which target device / target OS are you using ? iPhone & iPad
iOS only: Does this happens on device ? or on the simulator ? or on both ?
Mac only: x86 or i386 ?
Please provide any additional information below.
In V3.0 RC4, CCParallaxNode.m have a wrong implementation of -(void) removeChild:(CCNode*)node cleanup:(BOOL)cleanup. [code] [_parallaxArray removeObject:node]; [/code]
The code above cause crash when using ParallaxNode and dynamically remove children when they are out of screen. The node is not an object of CGPointObject. So the call of removeObject will never remove the object out of the array. This will later cause EXC_BAD_ACCESS in visit function because the parallax node still think that it still have the child node. When I reverse back to the implementation in Cocos2D V2.0, it works fine.
[code] for( unsigned int i=0;i < _parallaxArray.count;i++) { CGPointObject *point = [_parallaxArray objectAtIndex:i]; if( [point.child isEqual:node] ) { //ccArrayRemoveObjectAtIndex(_parallaxArray, i); [_parallaxArray removeObject:point]; break; } }
[super removeChild:node cleanup:cleanup];
[/code]
Status: New
Labels:
Type-Defect
Priority-Medium