0

我有一个可以正常工作的转换序列,直到我在序列末尾添加 removeAllChildrenWithCleanup: 。我该怎么做才能保持转换顺序并在最后运行 removeAllChildrenWithCleanup:?

这是有问题的代码片段:

// Note: spriteSheet is a CCSpriteBatchNode
CCArray *oldSprites = [spriteSheet descendants];
for (int j=0; j < (int)[oldSprites count]; j++) {
    CCSprite *sprite = (CCSprite *)[oldSprites objectAtIndex:j];
    if (sprite != nil) {
        id actionMove = [CCMoveTo actionWithDuration:0.75
                                            position:ccp(0,0)];
        [sprite runAction:actionMove];
    }
}
[spriteSheet removeAllChildrenWithCleanup:YES];

注意:我尝试通过使用 CCMoveTo 序列然后 CCCallFuncND 来清理精灵来清理精灵,但它也不起作用。我正在尝试使用 removeAllChildrenWithCleanup:,因为我知道从 CCSpriteBatchNode 中删除孩子非常慢。

4

1 回答 1

1

你试过CCCallBlock吗?像这样的东西:

id actionMove = [CCMoveTo actionWithDuration:0.75 position:ccp(0,0)];
id actionDelay = [CCCallBlock actionWithBlock:^{[sprite removeFromParentAndCleanup:YES]; }];
id sequence = [CCSequence actions:actionMove, actionDelay, nil];
[sprite runAction:sequence];
于 2012-10-20T21:48:29.917 回答