對 SKScene 進行子類化以實現主 SpriteKit 功能
SpriteKit 功能可以在 SKScene 的子類中實現。例如,遊戲可以在名為 GameScene 的 SKScene 子類中實現主要遊戲功能。
在 Swift 中 :
import SpriteKit
class GameScene: SKScene {
    override func didMoveToView(view: SKView) {
        /* Code here to setup the scene when it is first shown. E.g. add sprites. */
    }
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        for touch in touches {
            let location = touch.locationInNode(self)
            /* Code here to respond to a user touch in the scene at location */
        }
    }
    override func update(currentTime: CFTimeInterval) {
        /* Code here to perform operations before each frame is updated */
    }
}
然後可以在場景中使用的 SKSpriteNodes 的子類中實現輔助功能(請參閱子類化 SKSpriteNode )。