本文介绍了一次运行两个 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?
推荐答案
使用组操作.
来自精灵套件编程指南:
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!