Is it possible to run code inside of an SKAction sequence that isn't an SKAction?

506 views Asked by At

I have this SKAction sequence:

    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")
}

When this part below runs, I want to change the texture property of my node, but I can't figure out how to add that into the SKAction sequence.

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

There are 1 answers

0
Thunk On

Can you add another runBlock call?

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