문제

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;
}
도움이 되었습니까?

해결책

[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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top