From ec2510fd53b0e9ea31aa1da4539eeafbdefc3de2 Mon Sep 17 00:00:00 2001 From: 127-Z3R0 <81heti1bif@hft-stuttgart.de> Date: Wed, 13 May 2020 15:00:29 +0200 Subject: [PATCH] add Label to EntityManager and implement Labels to SettingsScene --- .../GoldWars/Entities/EntityManager.swift | 3 ++ GoldWars/GoldWars/SettingsScene.swift | 36 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/GoldWars/GoldWars/Entities/EntityManager.swift b/GoldWars/GoldWars/Entities/EntityManager.swift index 0f7166c..7ebaa2a 100644 --- a/GoldWars/GoldWars/Entities/EntityManager.swift +++ b/GoldWars/GoldWars/Entities/EntityManager.swift @@ -64,6 +64,9 @@ class EntityManager { scene.addChild(sliderNode.sliderKnob) scene.addChild(sliderNode.sliderLine) } + if let labelNode = entity.component(ofType: LabelComponent.self)?.labelNode { + scene.addChild(labelNode) + } } func remove(_ entity: GKEntity) { diff --git a/GoldWars/GoldWars/SettingsScene.swift b/GoldWars/GoldWars/SettingsScene.swift index 9453979..8eb22f5 100644 --- a/GoldWars/GoldWars/SettingsScene.swift +++ b/GoldWars/GoldWars/SettingsScene.swift @@ -26,7 +26,7 @@ class SettingsScene: SKScene { entityManager.add(Button(name: "StopMenuMusic", iconName: "", text: "ON/OFF", - position: CGPoint(x: self.size.width / 2, y: self.size.height / 2), + position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2), onButtonPress: { if SoundManager.sharedInstance.isMusicPlaying { SoundManager.sharedInstance.stopMenuMusic() @@ -39,7 +39,7 @@ class SettingsScene: SKScene { entityManager.add(Button(name: "StopMovingBackground", iconName: "", text: "MOVE/STOP", - position: CGPoint(x: self.size.width / 2, y: self.size.height / 2 - 100), + position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2 - 100), onButtonPress: { if BackgroundComponent.isMovingBackgroundEnabled { BackgroundComponent.isMovingBackgroundEnabled = false @@ -47,6 +47,38 @@ class SettingsScene: SKScene { BackgroundComponent.isMovingBackgroundEnabled = true } })) + entityManager.add(Label(fontnamed: "Courier-Bold", + name: "SettingsLabel", + text: "Settings", + fontSize: 200.0, + fontColor: .black, + position: CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.7), + horizontalAlignmentMode: .center, + vertikalAligmentMode: .baseline, + isAnimationEnabled: true, + isAnimationInfinite: true) + ) + entityManager.add(Label(fontnamed: "Courier-Bold", + name: "LabelMusic", + text: "Music", fontSize: 50.0, + fontColor: .black, + position: CGPoint(x: self.size.width * 0.5, y: self.size.height / 2 - 15), + horizontalAlignmentMode: .right, + vertikalAligmentMode: .baseline, + isAnimationEnabled: true, + isAnimationInfinite: false) + ) + entityManager.add(Label(fontnamed: "Courier-Bold", + name: "LabelBackground", + text: "Background", + fontSize: 50.0, + fontColor: .black, + position: CGPoint(x: self.size.width * 0.5, y: self.size.height / 2 - 115), + horizontalAlignmentMode: .right, + vertikalAligmentMode: .baseline, + isAnimationEnabled: true, + isAnimationInfinite: false) + ) entityManager.add(Background(size: self.size)) }