Search code examples
iosswiftnscodersktransition

How to convert Class types?


I'm trying to figure out how to convert class type so that I can go from my SKScene which is 'self' to my SCNScene which is GamePlay. And basically perform a scene normal scene transition.

enter image description here Code:

let scene = GamePlay(coder:NSCoder())
let transition = SKTransition.crossFadeWithDuration(1)
view?.presentScene(scene, transition: transition)

Solution

  • Try to cast you're scene to SKScene.

     let scene = GamePlay(coder:NSCoder())
     let transition = SKTransition.crossFadeWithDuration(1)
     if let skScene = scene as? SKScene {
            view?.presentScene(skScene, transition: transition)
     }