Is it possible to use the SceneEditor to layout & create a complex Subclass of SKSpriteNode, load that information and create a custom object in your scene based on the sks file?
My scenario is that I have a popup dialogs (which are nothing more than subclasses of SKSpriteNodes) with a lot of children on the dialog. I was hoping to lay it out in the Scene editor similar to how I lay out an SKScene, and then present it in my scene when needed.
I realize that I could just create this object in my GameScene.sks file, but find that those can get easily cluttered, and thought it might be a nicer way to store these dialgos if each had their own sks file.
I've tried extending SKSpriteNode to access the file similar to the Scene file but it didn't work
if let teamDialog = SKSpriteNode.spriteWithClassNamed(className: "TeamDialog", fileName: "TeamDialog.sks") { }
extension SKSpriteNode {
static func spriteWithClassNamed(className: String, fileName: String) -> SKSpriteNode? {
guard let dialog = SKSpriteNode(fileNamed: fileName) else {
return nil
}
return dialog
}
}
You can use this delegate https://github.com/ice3-software/node-archive-delegate
Or, smt like this in swift:
UPDATE for Swift 3 and fix class casting: