【问题标题】:Is it possible to run code inside of an SKAction sequence that isn't an SKAction?是否可以在不是 SKAction 的 SKAction 序列中运行代码?
【发布时间】:2015-06-21 16:38:10
【问题描述】:

我有这个 SKAction 序列:

    func move(){

    let recursive = SKAction.sequence([
        SKAction.moveByX(frame.size.width/2.8, y: 0, duration: NSTimeInterval(randomNumber())),
        SKAction.moveByX(-frame.size.width/2.8, y: 0, duration: NSTimeInterval(randomNumber())),
        SKAction.runBlock({self.move()})])
        doc.runAction(recursive, withKey: "move")
}

当下面这部分运行时,我想更改节点的纹理属性,但我不知道如何将其添加到 SKAction 序列中。

SKAction.moveByX(frame.size.width/2.8, y: 0, duration: NSTimeInterval(randomNumber()))

【问题讨论】:

    标签: swift sprite-kit sequence skaction sktexture


    【解决方案1】:

    你能添加另一个 runBlock 调用吗?

    SKAction.runBlock(
    { 
          //change the texture and whatever else you need here...
          doc.texture = someNewTexture;
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-14
      • 2013-10-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多