diff --git a/GoldWars/GoldWars/MatchmakingHelper.swift b/GoldWars/GoldWars/MatchmakingHelper.swift index 8a5ef28..63f1c89 100644 --- a/GoldWars/GoldWars/MatchmakingHelper.swift +++ b/GoldWars/GoldWars/MatchmakingHelper.swift @@ -40,8 +40,8 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe super.init() } - func presentMatchmaker() { - // menusc = scene + func presentMatchmaker(scene: MenuScene) { + menusc = scene print("I'm in 43") guard GKLocalPlayer.local.isAuthenticated else { print("Player ist nicht authentifiziert") @@ -110,10 +110,11 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe if mpMatch != match { return } // delegate?.matchReceivedData(match: match, data: data, fromPlayer: // playerID) + } private func match(match: GKMatch!, didFailWithError error: NSError!) { - print("I'm in 113") + print("Cant connect to any other player") if mpMatch != match { return } @@ -160,8 +161,10 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe self.serverPlayer = player } - self.delegate?.matchStarted() - // self.menusc!.loadScene(scene: GameScene(size: self.menusc!.size)) + /// self.delegate?.matchStarted() + print("spiel gefunden") + self.menusc!.loadScene(scene: GameScene(size: self.menusc!.size)) + print("scene müsste gewechselt sein") }) } diff --git a/GoldWars/GoldWars/Scenes/MenuScene.swift b/GoldWars/GoldWars/Scenes/MenuScene.swift index 10c7a8b..de73580 100644 --- a/GoldWars/GoldWars/Scenes/MenuScene.swift +++ b/GoldWars/GoldWars/Scenes/MenuScene.swift @@ -21,7 +21,9 @@ class MenuScene: SKScene { text: "Start Game", position: CGPoint(x: midX, y: midY), onButtonPress: { - MatchmakingHelper.sharedInstance.presentMatchmaker() + //let mmh = MatchmakingHelper() + //mmh.delegate = self + MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self) })) entityManager.add(Button(name: "settingsButton", iconName: "", @@ -47,10 +49,9 @@ class MenuScene: SKScene { } extension MenuScene: GameKitHelperDelegate{ + func matchStarted() { + print("Spiel gestartet") + } - func matchStarted() { - print("halo i bims") - self.loadScene(scene: GameScene(size: self.size)) - } }