SHARE
TWEET

Code

a guest Jan 27th, 2020 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let highScoreText: String
  2. let highScoreColor: UIColor
  3.  
  4. // Sets the high score label properties if the final score broke the high score
  5. if finalScore > highScore {
  6.     highScoreColor = AppColors.gold
  7.     highScoreText = "New High Score: \(finalScore)"
  8.  
  9.     StorageManager.saveNewHighScore(finalScore: finalScore)
  10. } else {
  11.     highScoreColor = .white
  12.     highScoreText = "High Score: \(highScore)"
  13. }
  14.  
  15. DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
  16.     [weak self] in
  17.  
  18.     // Removes all nodes after five seconds
  19.     self?.removeAllChildren()
  20.  
  21.     // Re-adds the background
  22.     let background = SKSpriteNode(imageNamed: "Background (About)")
  23.     background.name = "Background"
  24.     background.position = CGPoint(x: 512, y: 384)
  25.     background.zPosition = -1
  26.     self?.addChild(background)
  27.  
  28.     // Creates final result UI elements
  29.  
  30.     let finalScoreLabel = SKLabelNode()
  31.     finalScoreLabel.fontName = "Chalkduster"
  32.     finalScoreLabel.text = "Final score: \(finalScore)"
  33.     finalScoreLabel.position = CGPoint(x: 512, y: 440)
  34.     self?.addChild(finalScoreLabel)
  35.  
  36.     let highScoreLabel = SKLabelNode()
  37.     highScoreLabel.fontColor = highScoreColor
  38.     highScoreLabel.fontName = "Chalkduster"
  39.     highScoreLabel.text = highScoreText
  40.     highScoreLabel.position = CGPoint(x: 512, y: 350)
  41.     self?.addChild(highScoreLabel)
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top