xcode 由于缺少入口点无法到达场景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31460469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Scene is unreachable due to lack of entry points
提问by Darkstar
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?
我有一个游戏,如果你击中敌人,你就会进入游戏结束屏幕。我向 main.storyboard 添加了一个视图控制器并创建了类 GameOver。但是,它说我需要一个入口点,当我加载应用程序时,它只是一个空白屏幕。问题是,我真的不需要入口点,因为当敌人与玩家发生碰撞时,我正在代码中切换场景。不需要按钮“入口点”。如何解决这个问题?
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)
}
回答by Sumit Oberoi
Set a text for your storyboard ID
为故事板 ID 设置文本
回答by spongessuck
You need to set one of your ViewControllers as the initial view controller for your storyboard.
您需要将您的 ViewController 之一设置为故事板的初始视图控制器。
EDIT
编辑
You need a segue to your GameOver scene. Right now there's no way for your initial view controller to present it.
您需要对 GameOver 场景进行转场。现在您的初始视图控制器无法呈现它。