Reputation: 765
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?
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
Reputation: 1598
Error reason is the presence of the same viewController identifier! You need to give different viewController above storyBoard different identifier.
Upvotes: 1
Reputation: 1073
You need to set one of your ViewControllers as the initial view controller for your storyboard.
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