Reputation: 665
I have this code to switch from one SKScene to the other:
let nextScene = MenuScene(size: self.scene!.size)
let transition = SKTransition.revealWithDirection(.Down, duration: 1.0)
scene.scaleMode = .AspectFill
self.scene?.view?.presentScene(nextScene, transition: transition)
The new scene renders in a different background color than was specified in .sks and no nodes are visible. Sorry for the small amount of code, which i fear will not give much insight into my problem. Thanks for your help.
Upvotes: 1
Views: 45
Reputation: 16837
hamobi does have the correct answer, but this approach might be easier, and does not require an extension.
let nextScene = MenuScene(fileNamed:"MenuScene")
nextScene.size = self.scene!.size
let transition = SKTransition.revealWithDirection(.Down, duration: 1.0)
nextScene.scaleMode = .AspectFill
self.scene?.view?.presentScene(nextScene, transition: transition)
Note, moving from scene to scene like this is bad design, the scene should be telling the view that a transition is happening, and the view should be doing the presenting outside of the scene object, so that the old scene can properly deallocate
Upvotes: 2
Reputation: 8130
if youre creating it from an sks file then you need to instantiate the scene using your sks file. Check this out.. might help
Unarchiving .sks file in Swift for iOS 7.1
Upvotes: 2