sprite-kit Running a Block of Code in an SKAction


Example

One helpful case is to have the action run a block of code.

In Swift:

let node = SKSpriteNode(imageNamed: "image")
let actionBlock = SKAction.runBlock({
    //Do what you want here
    if let gameScene = node.scene as? GameScene {
        gameScene.score += 5
    }
})
node.runAction(actionBlock)