运行 在一个序列中同时执行两个动作

Run Two Action At The Same Time Inside ONE Sequence

我不确定我正在寻找的东西是否可行,但我只是在检查以确保我没有以困难的方式做事。

目前我有两个序列,它们同时 运行。每个序列从等待 3 秒开始,然后一个序列缩放一个节点,另一个序列调整该节点的 alpha。所以代码看起来像这样:

node.runAction(SKAction.sequence([animationWait, animationScale]))
node.runAction(SKAction.sequence([animationWait, animationAlpha]))

但是有没有办法 运行 在一个序列中同时设置 animationScale 和 animationAlpha?所以它看起来像这样(这不起作用,但我希望你能看到我正在尝试做的事情):

node.runAction(SKAction.sequence([animationWait, (animationScale, animationAlpha)]))

您可以将操作组合成一个序列:

var actions = Array<SKAction>()

actions.append(SKAction.sequence([animationWait, animationScale]))
actions.append(SKAction.sequence([animationWait, animationAlpha]))

let group = SKAction.group(actions)

node.runAction(group)

When the action executes, the actions that comprise the group all start immediately and run in parallel. The duration of the group action is the longest duration among the collection of actions. If an action in the group has a duration less than the group’s duration, the action completes, then idles until the group completes the remaining actions. This matters most when creating a repeating action that repeats a group.

我刚刚测试了一些东西,它似乎奏效了。而不是以下内容:

node.runAction(SKAction.sequence([animationWait, (animationScale, animationAlpha)]))

做:

node.runAction(SKAction.sequence([animationWait, [animationScale, animationAlpha]]))

我很惊讶它起作用了。我本来打算删除这个问题,但有人可能会觉得这很方便。

编辑:

以下不再有效

node.runAction(SKAction.sequence([animationWait, [animationScale, animationAlpha]]))

根据evilboxingdragonslayer的建议,你需要使用"group",见下文:

node.runAction(SKAction.sequence([animationWait, group([animationScale, animationAlpha])]))