2

从我的问题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)]];
}

我在我的应用程序中使用上面的代码。但我不需要这种方法。

上面的代码用于移动精灵。

我将代码放在此处只是因为您可以想象我需要什么。

现在我想一次移动 10 个精灵。

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

上线 - 一次移动一个精灵。

如何一次移动所有精灵。

为什么需要?:

你可能看过俄罗斯方块游戏。

如果最底部的行是完整的,那么上面的所有行都会向下移动一步。

我也想这样做。

如何?

4

2 回答 2

2

我已经通过以下链接。

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

答案如下。

产卵

Spawn 操作可让您同时运行多个操作。Spawn 动作的持续时间将是最长的子动作的持续时间。

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

[精灵运行动作:动作];

于 2009-10-13T22:16:28.770 回答
1

尝试使用并发 NSThreads,每个需要移动的精灵一个。

于 2009-10-08T15:15:01.543 回答