0
votes

I have an image in my SpriteNode, but the image is black and I have a black background in my app. How can I change the tint color from my image in my SpriteNode?

I tried already this:

    retryButton.color = UIColor.white
    retryButton.color = .white
    retryButton.tintColor = UIColor.white
    retryButton.tintColor = .white

This is my code:

    var retryButton: SKSpriteNode!

    retryButton = SKSpriteNode(imageNamed: "retryImage")
    retryButton.name = "retryButton"
    retryButton.color = .white
    retryButton.size = CGSize(width: 60, height: 60)
    retryButton.position = CGPoint(x: frame.midX, y: frame.midY -   100) 
    self.addChild(retryButton)

I want now that the Image I added to the SKSpriteNode is white, but the image is still black.

1

1 Answers

0
votes

You need to create a texture with the image first, and then create your retryButton with that texture as a SKSPriteNode, following should work:

    var retryButton: SKSpriteNode!
    let texture = SKTexture(imageNamed: "retryImage")
    retryButton = SKSpriteNode(texture: texture)
    retryButton.color = .white
    retryButton.position = CGPoint(x: frame.midX, y: frame.midY -   100)
    self.addChild(retryButton)