Darkstar
Darkstar

Reputation: 765

Scene is unreachable due to lack of entry points

I've got a game where if you hit an enemy, you go to the gameover screen. I added a view controller to main.storyboard and made the class GameOver. However, it says I need an entry point and when I load the app it is just a blank screen. The thing is, I dont really need an entry point because I am switching scenes in the code when an enemy collides with the player. No button "entry point" needed. How can this be fixed?

enter image description here

enter image description here

Here is the code for collision with enemy:

func CollisionWithEnemy(Enemy: SKShapeNode, Player: SKSpriteNode) {

    //Highscore
    var ScoreDefault = NSUserDefaults.standardUserDefaults()
    ScoreDefault.setValue(Score, forKey: "Score")
    ScoreDefault.synchronize()


    if (Score > Highscore) {
        var HighscoreDefault = NSUserDefaults.standardUserDefaults()
        HighscoreDefault.setValue(Score, forKey: "Highscore")
    }

    var gameOver:SKScene = GameOver(size: self.size)
    ScoreLabel.removeFromSuperview()
    Enemy.removeFromParent()
    Player.removeFromParent()
    self.view?.presentScene(gameOver, transition: transition)


}

Upvotes: 9

Views: 16942

Answers (3)

ylgwhyh
ylgwhyh

Reputation: 1598

Error reason is the presence of the same viewController identifier! You need to give different viewController above storyBoard different identifier. enter image description here

Upvotes: 1

Sumit Oberoi
Sumit Oberoi

Reputation: 3475

enter image description here

Set a text for your storyboard ID

Upvotes: 40

spongessuck
spongessuck

Reputation: 1073

You need to set one of your ViewControllers as the initial view controller for your storyboard.

init view controller option

EDIT

You need a segue to your GameOver scene. Right now there's no way for your initial view controller to present it.

Upvotes: 5

Related Questions