add finishButton to HUD

This commit is contained in:
Jakob Haag 2020-05-28 16:52:03 +02:00 committed by Aldin Duraki
parent bddd226ffd
commit 99b57cc4cd
2 changed files with 10 additions and 1 deletions

View File

@ -51,6 +51,7 @@ class EntityManager {
scene.addChild(hudEntitiy.atkSkill) scene.addChild(hudEntitiy.atkSkill)
scene.addChild(hudEntitiy.spySkill) scene.addChild(hudEntitiy.spySkill)
scene.addChild(hudEntitiy.roundTimerLabel) scene.addChild(hudEntitiy.roundTimerLabel)
scene.addChild(hudEntitiy.finishButton)
} }
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self) { if let spriteNode = entity.component(ofType: DefaultBaseComponent.self) {

View File

@ -27,14 +27,22 @@ class HUD: GKEntity {
var roundTimerLabel: SKLabelNode var roundTimerLabel: SKLabelNode
let roundTimer: RoundTimer let roundTimer: RoundTimer
var finishButton: ButtonNode
init(size: CGSize) { 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 host = GameCenterManager.sharedInstance.hostingPlayer
peer = GameCenterManager.sharedInstance.peerPlayer peer = GameCenterManager.sharedInstance.peerPlayer
hostLabel = SKLabelNode(text: host?.displayName) hostLabel = SKLabelNode(text: host?.displayName)
hostUnitsLabel = SKLabelNode(text: "500" ) hostUnitsLabel = SKLabelNode(text: "500" )
peerLabel = SKLabelNode(text: peer?.displayName) peerLabel = SKLabelNode(text: peer?.displayName)
peerUnitsLabel = SKLabelNode(text: "500") peerUnitsLabel = SKLabelNode(text: "500")
roundTimerLabel = SKLabelNode(text: "") roundTimerLabel = SKLabelNode(text: "")
roundTimerLabel.fontColor = UIColor.black roundTimerLabel.fontColor = UIColor.black
roundTimerLabel.fontSize = CGFloat(45) roundTimerLabel.fontSize = CGFloat(45)