NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

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 =


Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

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

Reply to this topic…

You need to create an account or log in to reply.

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.