在 SKAction 中运行代码块
一个有用的案例是让操作运行一段代码。
在 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)