是否可以在不是SKAction的SKAction序列中运行代码?

时间:2015-06-21 16:38:10

标签: swift sprite-kit sequence skaction sktexture

我有这个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()))

1 个答案:

答案 0 :(得分:3)

你可以添加另一个runBlock调用吗?

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