add Label to EntityManager and implement Labels to SettingsScene

This commit is contained in:
127-Z3R0 2020-05-13 15:00:29 +02:00
parent 1ca5399a2e
commit ec2510fd53
2 changed files with 37 additions and 2 deletions

View File

@ -64,6 +64,9 @@ class EntityManager {
scene.addChild(sliderNode.sliderKnob) scene.addChild(sliderNode.sliderKnob)
scene.addChild(sliderNode.sliderLine) scene.addChild(sliderNode.sliderLine)
} }
if let labelNode = entity.component(ofType: LabelComponent.self)?.labelNode {
scene.addChild(labelNode)
}
} }
func remove(_ entity: GKEntity) { func remove(_ entity: GKEntity) {

View File

@ -26,7 +26,7 @@ class SettingsScene: SKScene {
entityManager.add(Button(name: "StopMenuMusic", entityManager.add(Button(name: "StopMenuMusic",
iconName: "", iconName: "",
text: "ON/OFF", 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: { onButtonPress: {
if SoundManager.sharedInstance.isMusicPlaying { if SoundManager.sharedInstance.isMusicPlaying {
SoundManager.sharedInstance.stopMenuMusic() SoundManager.sharedInstance.stopMenuMusic()
@ -39,7 +39,7 @@ class SettingsScene: SKScene {
entityManager.add(Button(name: "StopMovingBackground", entityManager.add(Button(name: "StopMovingBackground",
iconName: "", iconName: "",
text: "MOVE/STOP", 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: { onButtonPress: {
if BackgroundComponent.isMovingBackgroundEnabled { if BackgroundComponent.isMovingBackgroundEnabled {
BackgroundComponent.isMovingBackgroundEnabled = false BackgroundComponent.isMovingBackgroundEnabled = false
@ -47,6 +47,38 @@ class SettingsScene: SKScene {
BackgroundComponent.isMovingBackgroundEnabled = true 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)) entityManager.add(Background(size: self.size))
} }