title: Sprite-Kit colorizeWithColor not blending the sprite with the correct color
body: <p>I have a sprite (healthbar) in my scene and I wish to colorize it whenever the player gets hit. I can colorize my sprite with greenColor, and blueColor. However, redColor, brownColor, yellowColor, cyanColor, and whiteColor all don't seem to work.</p>
  
  <p><strong>Sprite:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/TYJ4X.jpg" alt="enter image description here"> _healthBar</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>SKAction *pulseRed = [SKAction sequence:@[
  [SKAction colorizeWithColor:[SKColor redColor] colorBlendFactor:1.0 duration:0.15],
  [SKAction waitForDuration:0.1],
  [SKAction colorizeWithColorBlendFactor:0.0 duration:0.15]]];
  
  SKAction *repeat   = [SKAction repeatActionForever:pulseRed];
  
  [_healthBar runAction: repeat];
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/0tH0Q.gif" alt="enter image description here"> [SKColor redColor] Not Working</p>
  
  <p><strong>Other Colors:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/RhO2c.gif" alt="enter image description here"> [SKColor yellowColor] Not Working</p>
  
  <p><img src="https://i.stack.imgur.com/nsyPn.gif" alt="enter image description here"> [SKColor blueColor] Working</p>
  
  <p><img src="https://i.stack.imgur.com/whrLw.gif" alt="enter image description here"> [SKColor greenColor] Working</p>
  
  <p>The yellow seems to make sense, since yellow and blue make green. However, I don't think this is what's happening here.</p>
  
  <p>Any thoughts? </p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>There is a workaround, which other people have hinted at below, that works great with rectangular sprites (basically create a colored sprite on top of your textured one). However, I would like to find a solution that not just for rectangular sprites, since I will be using this strategy to colorize other sprites in my game.</p>
  
  <p><strong>Solution for colorizing a rectangular sprite (Ahmet Cevdet):</strong>   </p>
  
  <p>@interface</p>
  
  <pre><code>@property (strong, nonatomic) SKSpriteNode  *filterNode;
  </code></pre>
  
  <p>@implementation</p>
  
  <pre><code>CGSize filterSize = CGSizeMake(_healthBar.size.width, _healthBar.size.height);
  SKColor *filterColor = [SKColor redColor];
  
  _filterNode = [SKSpriteNode spriteNodeWithColor:filterColor size:filterSize];
  _filterNode.alpha = 0;
  [_healthBar addChild:_filterNode];
  
  SKAction *fadeIn = [SKAction fadeAlphaTo:.6 duration:.15];
  SKAction *fadeOut = [SKAction fadeAlphaTo:0 duration:.15];
  SKAction *wait = [SKAction waitForDuration:0.1];
  
  [_filterNode runAction:[SKAction repeatActionForever:[SKAction sequence:@[fadeIn,wait,fadeOut]]] withKey:@"pulseRed"];
  </code></pre>