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)
}
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? {

View File

@ -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",