diff --git a/GoldWars/GoldWars/Entities/EntityManager.swift b/GoldWars/GoldWars/Entities/EntityManager.swift index 5856ccf..0621bf1 100644 --- a/GoldWars/GoldWars/Entities/EntityManager.swift +++ b/GoldWars/GoldWars/Entities/EntityManager.swift @@ -66,10 +66,6 @@ class EntityManager { scene.addChild(spinningLogoEntity.warsLetteringNode) } - if let settingsButtonEntity = entity as? SettingsButton { - scene.addChild(settingsButtonEntity.settingsButton) - } - if let wayEntity = entity as? Way { scene.addChild(wayEntity.localWayComponent) } @@ -298,8 +294,8 @@ class EntityManager { } func changeSettingsButtonText(buttonName: String, text: String) { - let button = entities.filter{$0 is SettingsButton && ($0 as! SettingsButton).name == buttonName }[0] as! SettingsButton - button.settingsButton.label.text = text + let button = entities.filter{$0 is Button && ($0 as! Button).name == buttonName }[0] as! Button + button.component(ofType: ButtonComponent.self)?.buttonNode.label.text = text } func getHUD() -> HUD? { diff --git a/GoldWars/GoldWars/SettingsScene.swift b/GoldWars/GoldWars/SettingsScene.swift index 2a96085..b408c84 100644 --- a/GoldWars/GoldWars/SettingsScene.swift +++ b/GoldWars/GoldWars/SettingsScene.swift @@ -27,31 +27,33 @@ class SettingsScene: SKScene { let scene = MenuScene(size: self.size) self.loadScene(scene: scene) })) - entityManager.add(SettingsButton(name: "StopMenuMusic", - text: musicButtonText, - position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2), - onButtonPress: { - if SoundManager.sharedInstance.isMusicPlaying { - SoundManager.sharedInstance.stopMenuMusic() - SoundManager.sharedInstance.isMusicEnabled = false - self.entityManager.changeSettingsButtonText(buttonName: "StopMenuMusic", text: "OFF") - } else { - SoundManager.sharedInstance.isMusicEnabled = true - SoundManager.sharedInstance.startMenuMusic() - self.entityManager.changeSettingsButtonText(buttonName: "StopMenuMusic", text: "ON") - } + entityManager.add(Button(name: "StopMenuMusic", + textureName: "yellow_button04", + text: musicButtonText, + position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2), + onButtonPress: { + if SoundManager.sharedInstance.isMusicPlaying { + SoundManager.sharedInstance.stopMenuMusic() + SoundManager.sharedInstance.isMusicEnabled = false + self.entityManager.changeSettingsButtonText(buttonName: "StopMenuMusic", text: "OFF") + } else { + SoundManager.sharedInstance.isMusicEnabled = true + SoundManager.sharedInstance.startMenuMusic() + self.entityManager.changeSettingsButtonText(buttonName: "StopMenuMusic", text: "ON") + } })) - entityManager.add(SettingsButton(name: "StopMovingBackground", - text: "MOVE", - position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2 - 100), - onButtonPress: { - if BackgroundComponent.isMovingBackgroundEnabled { - BackgroundComponent.isMovingBackgroundEnabled = false - self.entityManager.changeSettingsButtonText(buttonName: "StopMovingBackground", text: "STOP") - } else { - BackgroundComponent.isMovingBackgroundEnabled = true - self.entityManager.changeSettingsButtonText(buttonName: "StopMovingBackground", text: "MOVE") - } + entityManager.add(Button(name: "StopMovingBackground", + textureName: "yellow_button04", + text: "MOVE", + position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2 - 100), + onButtonPress: { + if BackgroundComponent.isMovingBackgroundEnabled { + BackgroundComponent.isMovingBackgroundEnabled = false + self.entityManager.changeSettingsButtonText(buttonName: "StopMovingBackground", text: "STOP") + } else { + BackgroundComponent.isMovingBackgroundEnabled = true + self.entityManager.changeSettingsButtonText(buttonName: "StopMovingBackground", text: "MOVE") + } })) entityManager.add(Label(fontnamed: "Courier-Bold", name: "SettingsLabel",