Instead of creating a pauseNode
like you normally would in SpriteKit
, instead create another view above the ARSKView
.
Either in your storyboard or view controller, add another view that is pinned to be fullscreen. This can either be a UIView
or an SKView
, depending on whether you would like to use UIKit
or SpriteKit
to create your menu (labels, buttons, etc). I would recommend using UIKit
, since it is designed for building user interfaces.
The view hierarchy would look something like this:
-- UIViewController
-- UIView / SKView
-- ARSKView
To communicate between these views, set up a pause menu delegate to notify your view controller when buttons are pressed.
protocol PauseMenuViewDelegate: class {
func pauseMenuUnPauseButtonPressed()
}
In your pause menu view:
class PauseMenuView: UIView {
weak var delegate: PauseMenuViewDelegate?
@IBAction func unPauseButtonPressed() {
delegate?.pauseMenuUnPauseButtonPressed()
}
...
}
In your view controller:
class ViewController: UIViewController {
@IBOutlet weak var pauseMenuView: PauseMenuView! {
didSet { pauseMenuView.delegate = self }
}
...
}
extension ViewController: PauseMenuViewDelegate {
func pauseMenuUnPauseButtonPressed() {
// unpause the game here
}
}