Question

I want to change the color of an SKSpriteNode by score. Its color should change smoothly so I tried to use an SKAction. But, the color doesn't change.

if (score > 20) {

    SKAction *changeColor = [SKAction colorizeWithColor:self.color colorBlendFactor:0 duration:3];

    [self.sprite runAction:changeColor];


    return;
}
Was it helpful?

Solution

[SKAction colorizeWithColor:self.color colorBlendFactor:0 duration:3];

A colorBlendFactor of 0 means that the color takes no effect, ie the color values are multiplied with colorBlendFactor to compute the actual amount of color applied to each pixel. Change colorBlendFactor to 1 and you'll see the sprite being colorized.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top