简体   繁体   English

两个不同对象的CCActionSequence

[英]CCActionSequence for two different objects

I want to move two different objects, pane1 and pane2, simultaneously using CCActionMoveTo, and I want to call a function once these two objects finish moving. 我想使用CCActionMoveTo同时移动两个不同的对象pane1和pane2,并且要在这两个对象完成移动后调用一个函数。

CCActionMoveTo * actionMove1 =  [CCActionEaseOut actionWithAction:
                               [CCActionMoveTo actionWithDuration:.4
                                               position:ccp(pane1.position.x - 150, 0)]
                                               rate: 1.5];


CCActionMoveTo * actionMove2 =  [CCActionEaseOut actionWithAction:
                                [CCActionMoveTo actionWithDuration:.4
                                                          position:ccp(pane2.position.x - 150, 0)]
                                                            rate: 1.5];

[pane1 runAction: actionMove1];
[pane2 runAction: actionMove2];
[self generateTerrain];

How do I call these two actionMoves at the same time and wait until both are done to call generateTerrain? 如何同时调用这两个actionMove,然后等到两者都完成后再调用generateTerrain?

I would solve this by just making a timer that calls generate terrain after .4 seconds like this 我可以通过使计时器像这样在.4秒后调用生成地形来解决此问题

NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval: 0.4 target: self
                               selector: @selector(generateTerrain:) userInfo: nil repeats: NO];

As for executing the animations simultaneously, the code you have should run them at the same time as they are on different nodes 至于同时执行动画,您拥有的代码应该在不同节点上同时运行它们

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM