From 996800bc01843953e05c503179f60ad46e3b4ede Mon Sep 17 00:00:00 2001 From: Aldin Duraki <62dual1bif@hft-stuttgart.de> Date: Thu, 23 Apr 2020 23:01:19 +0200 Subject: [PATCH] Impl. HUD for GameScene --- GoldWars/GoldWars/Game/GameScene.swift | 45 +++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/GoldWars/GoldWars/Game/GameScene.swift b/GoldWars/GoldWars/Game/GameScene.swift index 8dcdebf..c8de31f 100644 --- a/GoldWars/GoldWars/Game/GameScene.swift +++ b/GoldWars/GoldWars/Game/GameScene.swift @@ -17,6 +17,18 @@ class GameScene: SKScene, SKPhysicsContactDelegate { var player = [Base]() var popUpOnBaseCollision = SKSpriteNode() + // TODO: Refactoring following as Components in Sprint 2 + var timer = SKLabelNode() + var backBtn = SKShapeNode(circleOfRadius: 40) + var backLabel = SKLabelNode() + var atkBoostSkill = SKShapeNode(circleOfRadius: 30) + var defBoostSkill = SKShapeNode(circleOfRadius: 30) + var spySkill = SKShapeNode(circleOfRadius: 30) + var atkBoostLabel = SKLabelNode() + var defBoostLabel = SKLabelNode() + var spyLabel = SKLabelNode() + // TODO: END + struct physicsBodyNumber { static let basePlayer1Number: UInt32 = 0b1 static let basePlayer2Number: UInt32 = 0b10 @@ -52,7 +64,6 @@ class GameScene: SKScene, SKPhysicsContactDelegate { createVirginBases() connectBases() addPhysicsBodyToBase() - } override func didMove(to view: SKView) { let background = SKSpriteNode(imageNamed: "Background") @@ -60,6 +71,38 @@ class GameScene: SKScene, SKPhysicsContactDelegate { background.zPosition = -1 background.size = self.size self.addChild(background) + + // TODO: Refactor following as Components in Sprint 2 + timer.text = "Roundtime: 30 Seconds left" + timer.fontColor = SKColor.black + timer.fontSize = 40 + timer.position = CGPoint(x: self.size.width/2, y: self.size.height * 0.9) + backBtn.position = CGPoint(x: 40, y: self.size.height * 0.9) + backBtn.fillColor = SKColor.gray + backLabel.text = "Back" + backLabel.position = CGPoint(x: backBtn.position.x, y: backBtn.position.y - 15) + spySkill.position = CGPoint(x: self.size.width * 0.75, y: 40) + spySkill.fillColor = SKColor.gray + spyLabel.text = "Spy" + spyLabel.position = CGPoint(x: spySkill.position.x, y: spySkill.position.y - 15); + atkBoostSkill.position = CGPoint(x: self.size.width * 0.85, y: 40) + atkBoostSkill.fillColor = SKColor.gray + atkBoostLabel.text = "Atk" + atkBoostLabel.position = CGPoint(x: atkBoostSkill.position.x, y: atkBoostSkill.position.y - 15) + defBoostSkill.position = CGPoint(x: self.size.width * 0.95, y: 40) + defBoostSkill.fillColor = SKColor.gray + defBoostLabel.text = "Def" + defBoostLabel.position = CGPoint(x: defBoostSkill.position.x, y: defBoostSkill.position.y - 15) + self.addChild(timer) + self.addChild(backBtn) + self.addChild(backLabel) + self.addChild(atkBoostSkill) + self.addChild(defBoostSkill) + self.addChild(spySkill) + self.addChild(atkBoostLabel) + self.addChild(defBoostLabel) + self.addChild(spyLabel) + // TODO: END }