BLACK FRIDAY SALE: Save 50% on all my Swift books and bundles! >>

SOLVED: Bubble Trouble issue

Forums > macOS

I just completed Pauls book Hacking with macOS up to Bubble Trouble (Swift UI addition). On the challenges I was able to find a solution to place "Game Over!" on the screen when all the bubbles are gone as expected. But expected the text to be blue as thats what I coded... Text remains white... Any clues to why this doesn't work? Heres a portion of the code:

  func pop(_ node: SKSpriteNode) {
        guard let index = bubbles.firstIndex(of: node) else { return }
        bubbles.remove(at: index)

        node.physicsBody = nil = nil

        let fadeOut = SKAction.fadeOut(withDuration: 0.3)
        let scaleUp = SKAction.scale(by: 1.5, duration: 0.3)
        let group =[fadeOut, scaleUp])

        let sequence = SKAction.sequence([group, SKAction.removeFromParent()])

        run(SKAction.playSoundFileNamed("pop.wav", waitForCompletion: false))

        if bubbles.count == 0 {
            endGame = SKLabelNode(fontNamed: "Marker-Felt")
            endGame.color =
            endGame.text = "Game Over!"
            endGame.fontSize = 128
            endGame.position = CGPoint(x: 400, y: 300)





SKLabelNode has a fontColor property for the text color, not a color property. The default font color is white. You didn't set the font color for the label so you end up with white text.

The following code change should give you blue text:

endGame.fontColor =


Save 50% in my Black Friday sale.

SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.