I would like to add a SKScene to my main GameScene. SKReferenceNode seems to be a good solution.
I have : - GameScene.sks (main scene) - Countdown.sks (scene to add to GameScene) - Countdown.swift (Custom class, how does to init it? SKScene ? SKReferenceNode ? SKNode)
I don't know how to add programmatically my countdown using my class Countdown.
I tried:
let path = Bundle.main.path(forResource: "Countdown", ofType: "sks")
let cd = SKReferenceNode (url: NSURL (fileURLWithPath: path!) as URL) as! Countdown
cd.name = "countdown"
self.addChild(cd)
But I have the following error :
Could not cast value of type 'SKReferenceNode' (0x10d97ad88) to 'LYT.Countdown' (0x10a5709d0
I also tried something more simple like:
let cd=Countdown(scene:self)
self.addChild(cd)
But I don't know how to init the class using the Countdown.sks file.
I know I also have the possibility to create a SKNode class, and init it 100% programmatically, but it really important for me to use the associated .sks file in order to use the Xcode scene editor.