I am working on a game and want to move the interface logic out of the game logic. The following is what I tried but does not work. What is the correct way to do this?
// Game scene & logic
class GameScene: SKScene, ObservableObject {
@EnvironmentObject var interfaceControls:InterfaceControls // This does not work
func gameOver() {
interfaceControls.isMenuShowing = true
}
}
// Interface state
class InterfaceControls: ObservableObject {
@Published var isMenuShowing = false
}