views:

302

answers:

2

From my Question here,


http://iphonegamedev.stackexchange.com/questions/82/moving-sprites-more-then-one-at-a-time


-(void)moveBox:(NSTimer*)myTimer{
 float endx=[[[myTimer userInfo] valueForKey:@"endX"] floatValue];
 float endy=[[[myTimer userInfo] valueForKey:@"endY"] floatValue];
 float timing=[[[myTimer userInfo] valueForKey:@"timeForMove"] floatValue];
 Sprite *sp=(Sprite*)[[myTimer userInfo] valueForKey:@"objSprite"];
 [sp runAction: [MoveBy actionWithDuration:timing position:ccp(endx,endy)]];
}

I use above code in my application. But I don't require this method.

Above code is for Moving the sprite.

I have placed here above code just because You can imagine what do I need.

Now I want to Move 10 sprites at a time.

 [sp runAction: [MoveBy actionWithDuration:timing position:ccp(endx,endy)]];

Above line - moves one sprite at a time.

How to move all sprites all together at once.

Why Required ? :

You might have seen tetris game.

If bottom most row is complete, then all above rows move down by step one.

I want to do the same.

How?

+1  A: 

Try using concurrent NSThreads, one for each sprite that needs to be moved.

luvieere
+1  A: 

I have gone through following link.

http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:actions_composition

The answer is following.

Spawn

The Spawn action lets you run several actions at the same time. The duration of the Spawn action will be the duration of the longest sub-action.

id action = [Spawn actions: [JumpBy actionWithDuration:2 position:ccp(300,0) height:50 jumps:4], [RotateBy actionWithDuration: 2 angle: 720], nil];

[sprite runAction:action];

sugar