本文介绍了一次运行两个SKAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个序列来运行SKAction列表.但是,我要执行的是运行SKAction,然后一次运行两个,然后依次运行一个.
I'm using a sequence to run a list of SKActions. What I want to do however, is run an SKAction, then run two at once, then run one in sequence.
这是我的代码:
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];
}
我该怎么做?我以为我不能使用序列?
How can I accomplish this? I'm assuming I can't use a sequence?
推荐答案
使用组操作.
摘自Sprite Kit编程指南:
From sprite kit programming guide:
组操作是一组操作,这些操作在执行组后立即开始执行.当您要同步操作时,可以使用组
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];
这篇关于一次运行两个SKAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!