我正在使用一个序列来运行 SKActions 列表。然而,我想做的是运行一个 SKAction,然后一次运行两个,然后按顺序运行一个。
这是我的代码:
SKNode *ballNode = [self childNodeWithName:@"ball"];
if (ballNode != Nil){
ballNode.name = nil;
SKAction *delay = [SKAction waitForDuration:3];
SKAction *scale = [SKAction scaleTo:0 duration:1];
SKAction *fadeOut = [SKAction fadeOutWithDuration:1];
SKAction *remove = [SKAction removeFromParent];
//put actions in sequence
SKAction *moveSequence = [SKAction sequence:@[delay, (run scale and fadeout at the same time), remove]];
//run action from node (child of SKLabelNode)
[ballNode runAction:moveSequence];
}
我怎样才能做到这一点?我假设我不能使用序列?
最佳答案
使用群组操作。
来自 Sprite 套件编程指南:
组操作是一组操作,所有操作在组执行后立即开始执行。当您希望同步操作时可以使用组
SKSpriteNode *wheel = (SKSpriteNode*)[self childNodeWithName:@"wheel"];
CGFloat circumference = wheel.size.height * M_PI;
SKAction *oneRevolution = [SKAction rotateByAngle:-M_PI*2 duration:2.0];
SKAction *moveRight = [SKAction moveByX:circumference y:0 duration:2.0];
SKAction *group = [SKAction group:@[oneRevolution, moveRight]];
[wheel runAction:group];
关于objective-c - 同时运行两个 SKAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40395456/