0

这有效:

for (Object *oneObj in allObjects) {

    id moveAction = [CCMoveTo actionWithDuration:0.3f position:ccp(tx, ty)];
    id rotateAction = [CCRotateTo actionWithDuration:0.3 angle:0.0f];

    id action = [CCSpawn actions:moveAction, rotateAction, nil];
    id sequence = [CCSequence actions: action,
                                     [CCDelayTime actionWithDuration:0.1f],
                                     nil];

    [oneObj runAction:sequence];
}

这不起作用(这个对象只移动了一个对象):

id moveAction = [CCMoveTo actionWithDuration:0.3f position:ccp(tx, ty)];
id rotateAction = [CCRotateTo actionWithDuration:0.3 angle:0.0f];

id action = [CCSpawn actions:moveAction, rotateAction, nil];
id sequence = [CCSequence actions: action,
                          [CCDelayTime actionWithDuration:0.1f],
                          nil];

for (Object *oneObj in allObjects) {
     [oneObj runAction:sequence];
}

为什么?

4

1 回答 1

2

因为一个动作只能在一个节点上运行。您必须复制序列,以便每个对象运行自己的序列副本:

[oneObj runAction:[sequence copy]];
于 2013-03-06T19:21:20.740 回答