MysteryPancake MysteryPancake - 5 months ago 65
Swift Question

Swift: SKLabelNode fade animation doesn't fade

I'm just trying to make a SKLabelNode fade in, here's my code:

let welcome = SKLabelNode(text: "Welcome")
welcome.fontName = "HelveticaNeue-Light"
welcome.fontSize *= size.width/welcome.frame.width
welcome.fontColor = UIColor(white:1,alpha:0)
welcome.horizontalAlignmentMode = .center
welcome.verticalAlignmentMode = .center
welcome.position = CGPoint(x:size.width/2,y:size.height/2)

let fadein = SKAction.fadeIn(withDuration: 1)
let remove = SKAction.removeFromParent()[fadein,remove]))

But it doesn't work, and I can't figure out why. The strange part is the removeFromParent part works fine, just not the fade in. I already tried changing the font, making the label fade out and even making a custom action that changes the alpha, all of which have failed. I just can't figure out what the problem is.


Set the SKLabelNode's alpha to 0 before running the fadeIn() action on it.