DNESS / cocos2d-iphone

Automatically exported from code.google.com/p/cocos2d-iphone
1 stars 0 forks source link

CCParallaxNode incorrect implementation of -(void) removeChild:(CCNode*)node cleanup:(BOOL)cleanup #1515

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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]

Original issue reported on code.google.com by thien...@gmail.com on 23 Mar 2014 at 3:19