Search code examples
iossprite-kitskspritenodesknode

Subclassing SKNodes created with SpriteKit .sks scene file


(this is for XCode 6 and iOS 8 beta 4)

Love the new SceneKit editor. I'm successfully loading the scene from .sks file into a custom SKScene class. However, objects inside it are instantiated as default classes (SKNode, SKSpriteNode, etc), and i'm not sure how to bind them to be instantiated as custom subclasses instead.

Currently, I'm getting around that by creating custom classes and linking to sprite nodes as a property, and that works ok


Solution

  • I wrote a little helper delegate to deal with this: https://github.com/ice3-software/node-archive-delegate. It uses the NSKeyedUnarchiverDelegate to subclass your sprites by name.