代码之家  ›  专栏  ›  技术社区  ›  Lalit Prabhu

如何定期更改SKActions?

  •  0
  • Lalit Prabhu  · 技术社区  · 9 年前

    我想在生成几个矩形(SKShapeNodes)后更改速度OfRectangle。

    func wait(factor: CGFloat = 1) -> SKAction {
        return SKAction.waitForDuration(NSTimeInterval(rectHeight * speedOfRectangle * distanceBetweenRectangles / factor))
    }
    
    let spawnSequence = SKAction.sequence([wait(), increaseCounter, spawnAction])
    let spawnSequenceForever = SKAction.repeatActionForever(spawnSequence)
    
    worldNode.runAction(spawnSequenceForever)
    

    如何定期更改SKActions?

    1 回复  |  直到 9 年前
        1
  •  0
  •   Michael Berk    9 年前

    更改操作的最简单方法是删除旧操作并创建新操作。您可以通过使用“键”删除来删除操作,或者只需使用 removeAllActions() .

    在操作完成并再次运行之前,在操作运行时更改操作不会生效。

    希望这有所帮助,祝你好运。