New to Stackoverflow so sorry if I posted it wrong! Thanks
My App is a maze game with a time limit, once the time hits 0 the game ends and it goes to a game over screen (separate swift file), this consists of a "Replay" button which when pressed only shows the gamescene.sks file and not the gamescene.swift file (therefore none of the functions work). Is there a way to show both?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let node = self.nodeAtPoint(location) //1
if node.name == "replay" { //2
let reveal : SKTransition = SKTransition.flipHorizontalWithDuration(1)
let scene = GameScene(size: self.size)
scene.scaleMode = .AspectFill
self.view?.presentScene(scene, transition: reveal)
let reveal2 : SKTransition = SKTransition.flipHorizontalWithDuration(1)
let sksScene = SKScene(fileNamed: "GameScene.sks")
sksScene!.scaleMode = .AspectFill
self.view?.presentScene(sksScene!, transition: reveal2)
}
}
}
You need to ensure you're using your GameScene subclass when loading your GameScene.sks
let skView = self.view as SKView!
let transition = SKTransition.flipHorizontalWithDuration(0.5)
let scene = GameScene(fileNamed:"GameScene") as GameScene!
scene.scaleMode = .AspectFill
skView.presentScene(scene, transition: transition)
You only need to use presentScene
once :]