I am currently making my first game. I have a collision function ballCollideWithWall(_:Ball:)
which is called as expected, but the game over scene is not presenting. I verified that the collision function is called by using NSLog
.
// game over function
func gameOver(){
// presenting Game Over Scene
let transition = SKTransition.fadeWithDuration(1.5)
self.view?.presentScene(GameOverScene(), transition: transition)
}
which is then called in my function for the collision as
func ballCollideWithWall(Wall: SKSpriteNode, Ball: SKSpriteNode) {
gameOver()
}
You are presenting the scene in wrong way. You should change your code like
let scene = GameOverScene(size: self.view!.bounds.size)
self.view!.presentScene(scene, transition: transition)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.