SKAction changes the color of SKShapeNode

I use the repeatActionForever method from SKAction to change the color of the SKShapeNode. Here is my code:

SKShapeNode *ship = [SKShapeNode node]; [ship setPath:CGPathCreateWithRoundedRect(CGRectMake(-15, -15, 40, 17), 6.25, 6.25, nil)]; ship.fillColor = [SKColor redColor]; ship.glowWidth = 3; [ship runAction:[SKAction repeatActionForever:[SKAction sequence:@[ [SKAction colorizeWithColor:[SKColor blueColor] colorBlendFactor:1.0 duration:0.5], [SKAction waitForDuration:0.3],[SKAction colorizeWithColorBlendFactor:1.0 duration:0.5], [SKAction colorizeWithColor:[SKColor redColor] colorBlendFactor:1.0 duration:0.5], [SKAction waitForDuration:0.3], [SKAction colorizeWithColorBlendFactor:1.0 duration:0.5], [SKAction waitForDuration:0.3]]]]]; return ship; //because it a method 

It looks right, but the ship does not change color. What am I doing wrong, thanks.

+6
source share
1 answer

Unlike SKSpriteNode , a SKShapeNode does not have a color property. So your action colorizeWithColor: will not work.

Take a look at this post on how to animate fillColor and strokeColor : SKShapeNode - change animation color

+4
source

All Articles