Is it possible to use SceneEditor to build and create a complex subclass of SKSpriteNode, load this information and create a custom object in your scene based on the sks file?
My scenario is that I have popup dialogs (which are nothing more than subclasses of SKSpriteNodes) with lots of children in the dialog box. I was hoping to put it in the scene editor, similar to how I lay out SKScene, and then present it in my scene when necessary.
I understand that I could just create this object in my GameScene.sks file, but found that they could easily be cluttered, and thought it might be a more convenient way to save these dialogs if each of them has its own sks file .
I tried to extend SKSpriteNode to access a file similar to a scene file, but it did not 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
}
}

source
share