首页 > 解决方案 > 快速获取SKAction.repeat的循环索引

问题描述

我正在寻找一种方法来获取 SKAction.repeat 循环的循环索引。

在下面的代码中,我想用重复的索引替换“LOOP_INDEX”。

这甚至可能吗?

node.run(SKAction.sequence([
    SKAction.run { node.physicsBody?.affectedByGravity = false },
// HERE
    SKAction.repeat(SKAction.moveBy(x: 0, y: jumpHeight / CGFloat(sequences), duration: sequenceTimes[LOOP_INDEX]), count: sequences - 1),
    SKAction.run { node.physicsBody?.affectedByGravity = true },
    SKAction.moveBy(x: 0, y: jumpHeight / CGFloat(sequences), duration: sequenceTimes[2]),
]), withKey: "jump")

感谢您的回答;)

标签: iosswiftloopssprite-kit

解决方案


推荐阅读