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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:29:34  来源:igfitidea点击:

Scene is unreachable due to lack of entry points

iosxcodeswiftsprite-kit

提问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。但是,它说我需要一个入口点,当我加载应用程序时,它只是一个空白屏幕。问题是,我真的不需要入口点,因为当敌人与玩家发生碰撞时,我正在代码中切换场景。不需要按钮“入口点”。如何解决这个问题?

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)


}

回答by Sumit Oberoi

enter image description here

在此处输入图片说明

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 之一设置为故事板的初始视图控制器。

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.

您需要对 GameOver 场景进行转场。现在您的初始视图控制器无法呈现它。

回答by ylgwhyh

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

错误原因是存在相同的 viewController 标识符!您需要为 storyBoard 上方的不同 viewController 提供不同的标识符。 在此处输入图片说明