Something like this:
bug.color = SKColorWithRGB(128, 128, 128);
bug.colorBlendFactor = 1.0f;
Should definitely tint the sprite of choosing. The thing is that this is non intensive blend. Using a CIFilter with an SKEffectsNode is very very intensive for such a simple task.
I have an example below that blends a sprite with a red tinting, making the the sprite red tinted rather it's original color of orange:
- (instancetype)init
{
if (self = [super init]) {
self.physicsBody.categoryBitMask = PCFireBugCategory;
self.physicsBody.collisionBitMask = PCPlayerCategory | PCWallCategory | PCBreakableCategory | PCBoundaryCategory;
//Keeps the bugs from sliding too far when bumped
self.physicsBody.linearDamping = 1;
self.physicsBody.angularDamping = 1;
self.color = [SKColor redColor];
self.colorBlendFactor = 0.45;
}
return self;
}
I would also like to point out that this class is a subclass of SKSpriteNode.
Attached below is an example where I've applied the red tint using the exact code above.
Raywenderlich has a nice quote describing blending effects:
Note: Because the tint color is multiplied by the original color to
get the final result, if you set the color of a sprite to blue the end
result won’t necessarily be blue – it depends on what the original
color is. Because of this, if you want to dynamically set a sprite’s
color to a specific color, it is convenient to make the source color
of the sprite white (like the cat in Zombie Conga). If you want parts
of your sprite to be different colors, you can also split your sprite
into different parts, each of which you tint to a different color. For
more information, see the Beat ‘Em Up Game Starter Kit available at
raywenderlich.com.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…