从CCParallaxNode中删除子项

时间:2014-06-09 17:01:46

标签: ios objective-c ios7 cocos2d-iphone

我正在使用CCParallaxNode添加一些具有不同parallaxRatios和z的精灵(云)。当云离开屏幕时,我想从CCParallaxNode中删除它们。但是当我这样做时,我收到一个错误:

error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x20).
The process has been returned to the state before expression evaluation.

CCParallaxNode尝试访问其子位置时,{1}}的访问方法会抛出此错误:

-(void) visit
{
    CGPoint pos = [self absolutePosition_];
    if( ! CGPointEqualToPoint(pos, _lastPosition) ) {
        for (CGPointObject *point in _parallaxArray) {
            float x = -pos.x + pos.x * point.ratio.x + point.offset.x;
            float y = -pos.y + pos.y * point.ratio.y + point.offset.y;
            point.child.position = ccp(x,y); //error is thrown here
        }
        _lastPosition = pos;
    }
    [super visit];
}

这就是我删除子节点的方法:

    [_parallax addChild:cloud z:-z parallaxRatio:ccp(1/(CGFloat)z,0) positionOffset:cloud.position];
    CGFloat life = 6;
    [cloud runAction:[CCActionSequence actionWithArray:@[[CCActionDelay actionWithDuration:life],[CCActionCallBlock actionWithBlock:^(){
        [_parallax removeChild:cloud cleanup:YES];
    }]]]];

0 个答案:

没有答案
相关问题