swift - 在一个序列中同时运行两个 Action

标签 swift sprite-kit sequence skaction

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

目前我有两个序列,它们同时运行。每个序列从等待 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.

关于swift - 在一个序列中同时运行两个 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31119505/

相关文章:

swift - 如何使用 FileManager 执行 Finder 等特权操作?

ios - 如何更改 UISearchController 中 UISearchBar 的颜色

swift - 只有特定的包标识符找不到框架错误

ios - 如何以编程方式生成弹出 View Controller ?

ios - 在 SKScene 中获取屏幕边界 - didMoveToView(...)

algorithm - 序列与任何相邻产品的组合不超过给定数量

sql - 可以在 Oracle 的 SELECT 中执行自动编号序列吗?

swift - 使用 Sprite Kit 和 iOS 在游戏结束时显示插页式 admob

ios - Spritekit - Tableview 滚动中断

r - 如何将 "NA"添加到具体标识位置的向量中?