Ignore the last two Commits -> stupidy impact

* Access to ButtonNode via Component
* revert work and implement everything needed
This commit is contained in:
127-Z3R0 2020-06-25 14:39:31 +02:00
parent 6970f27a61
commit bf50703b1c
2 changed files with 28 additions and 30 deletions

View File

@ -66,10 +66,6 @@ class EntityManager {
scene.addChild(spinningLogoEntity.warsLetteringNode) scene.addChild(spinningLogoEntity.warsLetteringNode)
} }
if let settingsButtonEntity = entity as? SettingsButton {
scene.addChild(settingsButtonEntity.settingsButton)
}
if let wayEntity = entity as? Way { if let wayEntity = entity as? Way {
scene.addChild(wayEntity.localWayComponent) scene.addChild(wayEntity.localWayComponent)
} }
@ -298,8 +294,8 @@ class EntityManager {
} }
func changeSettingsButtonText(buttonName: String, text: String) { func changeSettingsButtonText(buttonName: String, text: String) {
let button = entities.filter{$0 is SettingsButton && ($0 as! SettingsButton).name == buttonName }[0] as! SettingsButton let button = entities.filter{$0 is Button && ($0 as! Button).name == buttonName }[0] as! Button
button.settingsButton.label.text = text button.component(ofType: ButtonComponent.self)?.buttonNode.label.text = text
} }
func getHUD() -> HUD? { func getHUD() -> HUD? {

View File

@ -27,31 +27,33 @@ class SettingsScene: SKScene {
let scene = MenuScene(size: self.size) let scene = MenuScene(size: self.size)
self.loadScene(scene: scene) self.loadScene(scene: scene)
})) }))
entityManager.add(SettingsButton(name: "StopMenuMusic", entityManager.add(Button(name: "StopMenuMusic",
text: musicButtonText, textureName: "yellow_button04",
position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2), text: musicButtonText,
onButtonPress: { position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2),
if SoundManager.sharedInstance.isMusicPlaying { onButtonPress: {
SoundManager.sharedInstance.stopMenuMusic() if SoundManager.sharedInstance.isMusicPlaying {
SoundManager.sharedInstance.isMusicEnabled = false SoundManager.sharedInstance.stopMenuMusic()
self.entityManager.changeSettingsButtonText(buttonName: "StopMenuMusic", text: "OFF") SoundManager.sharedInstance.isMusicEnabled = false
} else { self.entityManager.changeSettingsButtonText(buttonName: "StopMenuMusic", text: "OFF")
SoundManager.sharedInstance.isMusicEnabled = true } else {
SoundManager.sharedInstance.startMenuMusic() SoundManager.sharedInstance.isMusicEnabled = true
self.entityManager.changeSettingsButtonText(buttonName: "StopMenuMusic", text: "ON") SoundManager.sharedInstance.startMenuMusic()
} self.entityManager.changeSettingsButtonText(buttonName: "StopMenuMusic", text: "ON")
}
})) }))
entityManager.add(SettingsButton(name: "StopMovingBackground", entityManager.add(Button(name: "StopMovingBackground",
text: "MOVE", textureName: "yellow_button04",
position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2 - 100), text: "MOVE",
onButtonPress: { position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2 - 100),
if BackgroundComponent.isMovingBackgroundEnabled { onButtonPress: {
BackgroundComponent.isMovingBackgroundEnabled = false if BackgroundComponent.isMovingBackgroundEnabled {
self.entityManager.changeSettingsButtonText(buttonName: "StopMovingBackground", text: "STOP") BackgroundComponent.isMovingBackgroundEnabled = false
} else { self.entityManager.changeSettingsButtonText(buttonName: "StopMovingBackground", text: "STOP")
BackgroundComponent.isMovingBackgroundEnabled = true } else {
self.entityManager.changeSettingsButtonText(buttonName: "StopMovingBackground", text: "MOVE") BackgroundComponent.isMovingBackgroundEnabled = true
} self.entityManager.changeSettingsButtonText(buttonName: "StopMovingBackground", text: "MOVE")
}
})) }))
entityManager.add(Label(fontnamed: "Courier-Bold", entityManager.add(Label(fontnamed: "Courier-Bold",
name: "SettingsLabel", name: "SettingsLabel",