gpt4 book ai didi

objective-c - 一次运行两个 SKActions

转载 作者:太空狗 更新时间:2023-10-30 03:11:04 26 4
gpt4 key购买 nike

我正在使用序列来运行 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 kit 编程指南:

组 Action 是一组 Action 的集合,这些 Action 在组执行后立即开始执行。当您希望同步操作时,您可以使用群组

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 - 一次运行两个 SKActions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19779608/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com