From 99b57cc4cdbea9b9356ddce958bf7fddd67f3d74 Mon Sep 17 00:00:00 2001 From: Jakob Haag Date: Thu, 28 May 2020 16:52:03 +0200 Subject: [PATCH] add finishButton to HUD --- GoldWars/GoldWars/Entities/EntityManager.swift | 1 + GoldWars/GoldWars/Entities/HUD.swift | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/GoldWars/GoldWars/Entities/EntityManager.swift b/GoldWars/GoldWars/Entities/EntityManager.swift index b115459..b739eca 100644 --- a/GoldWars/GoldWars/Entities/EntityManager.swift +++ b/GoldWars/GoldWars/Entities/EntityManager.swift @@ -51,6 +51,7 @@ class EntityManager { scene.addChild(hudEntitiy.atkSkill) scene.addChild(hudEntitiy.spySkill) scene.addChild(hudEntitiy.roundTimerLabel) + scene.addChild(hudEntitiy.finishButton) } if let spriteNode = entity.component(ofType: DefaultBaseComponent.self) { diff --git a/GoldWars/GoldWars/Entities/HUD.swift b/GoldWars/GoldWars/Entities/HUD.swift index 0d6c4f7..6c08562 100644 --- a/GoldWars/GoldWars/Entities/HUD.swift +++ b/GoldWars/GoldWars/Entities/HUD.swift @@ -27,14 +27,22 @@ class HUD: GKEntity { var roundTimerLabel: SKLabelNode let roundTimer: RoundTimer + var finishButton: ButtonNode + init(size: CGSize) { + finishButton = ButtonNode(textureName: "yellow_button04", text: "Finish Round", isEnabled: true, position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.15, y: EntityManager.gameEMInstance.scene.size.height * 0.1), + onButtonPress: { print("Finish Round") } + ) + finishButton.size = CGSize(width: 225, height: 40) + finishButton.zPosition = 4 + host = GameCenterManager.sharedInstance.hostingPlayer peer = GameCenterManager.sharedInstance.peerPlayer hostLabel = SKLabelNode(text: host?.displayName) hostUnitsLabel = SKLabelNode(text: "500" ) peerLabel = SKLabelNode(text: peer?.displayName) peerUnitsLabel = SKLabelNode(text: "500") - + roundTimerLabel = SKLabelNode(text: "") roundTimerLabel.fontColor = UIColor.black roundTimerLabel.fontSize = CGFloat(45)