2

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()
}
Andrew Hershberger
  • 4,152
  • 1
  • 25
  • 35
joey2308
  • 21
  • 1
  • maybe you could try this instead on your update? if (CGRectContainsPoint(Wall.frame, Ball.frame)) { NSLog(@"touched"); [self Gameover]; } – StackBuddy Jul 22 '15 at 16:38
  • what happens when the scene is displayed? please give a description so I can give an accurate answer – Jesse Onolemen Jul 25 '15 at 22:15

1 Answers1

0

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)
Çağatay Kaya
  • 417
  • 1
  • 6
  • 19