I have an array of sprites and r开发者_StackOverflow社区un an action on each element. the issue I am having is that the last sprite is the only one that moves.
If I add 3 arrays and iterate through each and use the following
CCRepeatForever *repeat = [CCRepeatForever actionWithAction:moveSequence];
    [[row1 objectAtIndex:i] runAction:repeat];
it only move the last drawn sprite.
How does one run an action on every element in an Array?
I need the objects to move at the same time. So all sprites should run the action simultaneously. Is this possible with cocos2d
EDIT*****************
- (void) moveAliens
{
    id left = [CCMoveBy actionWithDuration:10 position:ccp(-35, 0)];
    id right = [CCMoveBy actionWithDuration:10 position:ccp(35, 0)];
    id moveSequence = [CCSequence actions:left, [CCDelayTime actionWithDuration:20],     right, [CCDelayTime actionWithDuration:20], nil];
    id repeatMoveSequence = [CCRepeatForever actionWithAction:moveSequence];
for (int i = 0; i < [row1 count]; i++) 
{
    NSLog(@"i is %d", i);
    //CCRepeatForever *repeat = [CCRepeatForever actionWithAction:moveSequence];
    [[row1 objectAtIndex:i] runAction:repeatMoveSequence];
}
}
Thanks
Place:
left = [CCMoveBy actionWithDuration:10 position:ccp(-35, 0)];
right = [CCMoveBy actionWithDuration:10 position:ccp(35, 0)];
moveSequence = [CCSequence actions:left, [CCDelayTime actionWithDuration:20],     right, [CCDelayTime actionWithDuration:20], nil];
repeatMoveSequence = [CCRepeatForever actionWithAction:moveSequence];
inside your for loop. And the variable declarations above it.
You can't use one CCAction for multiple CCNodes simultaneously.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论