首页 文章

在Spift中从SpriteKit场景切换到UIView

提问于
浏览
1

我正在开发Swift SpriteKit游戏,我需要一些帮助 . 我有游戏运行的游戏场景,当玩家死亡时,我想加载另一个带有按钮和标记的场景,但我希望这个场景是UIView而不是SpriteKit场景 . 如何从SpriteKit场景加载UIView?适用于现场?非常感谢!

1 回答

  • 3

    如果您只想显示弹出菜单,可以访问SKScene的视图并将 UIView 添加为子视图:

    self.view?.addSubview(yourView)
    

    或者,如果您想移动到另一个 UIViewcontroller ,您可以访问视图的 rootViewController 并从那里显示您的viewcontroller:

    self.view?.window?.rootViewController?.presentViewController(viewControllerToPresent: YourViewController, animated: true, completion: nil)
    

相关问题