-1

When ever my game pauses, the text hides. I have no clue why but I can't figure it out. Here is my code:

self.isPaused == true
if let label = self.label1 {
    label.alpha = 0.0
    label.run(SKAction.fadeIn(withDuration: 0.0))
    self.label = self.childNode(withName: "//Game Over") as? SKLabelNode

    if let label = self.label {
        label.alpha = 0.0
        label.run(SKAction.fadeIn(withDuration: 0.0))
        if(_hide == true){
            label.text = "hello"
        } else {
            label.text = "Game Over!!"
            label.isHidden = false
        }
    }
}

My text is disappearing if I pause the scene but if I don't pause, it won't hide it.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Jordan Heath
  • 114
  • 8

1 Answers1

0

With this line

label.alpha = 0.0

you are always hiding the text.

Then you run this action

label.run(SKAction.fadeIn(withDuration: 0.0))

which restore the visibility of the text (bringing alpha back to 1.0).

However actions are not executed when the game is paused. This explain the behaviour you are experiencing.

Wrap up

Remove these couple of lines in both your if bodies.

label.alpha = 0.0
label.run(SKAction.fadeIn(withDuration: 0.0))
Luca Angeletti
  • 58,465
  • 13
  • 121
  • 148