我正在开发Swift SpriteKit游戏,我需要一些帮助 . 我有游戏运行的游戏场景,当玩家死亡时,我想加载另一个带有按钮和标记的场景,但我希望这个场景是UIView而不是SpriteKit场景 . 如何从SpriteKit场景加载UIView?适用于现场?非常感谢!
如果您只想显示弹出菜单,可以访问SKScene的视图并将 UIView 添加为子视图:
UIView
self.view?.addSubview(yourView)
或者,如果您想移动到另一个 UIViewcontroller ,您可以访问视图的 rootViewController 并从那里显示您的viewcontroller:
UIViewcontroller
rootViewController
self.view?.window?.rootViewController?.presentViewController(viewControllerToPresent: YourViewController, animated: true, completion: nil)
1 回答
如果您只想显示弹出菜单,可以访问SKScene的视图并将
UIView
添加为子视图:或者,如果您想移动到另一个
UIViewcontroller
,您可以访问视图的rootViewController
并从那里显示您的viewcontroller: