问题
I was wondering if it was possible to invert the colors (or adjust the hue) of a SKSpriteNode.
回答1:
You can invert the colors by applying a CIFilter with an SKEffect node. Something like this should work:
SKEffectNode *effectNode = [[SKEffectNode alloc] init];
effectNode.filter = [CIFilter filterWithName:@"CIColorInvert"];
SKSpriteNode *node = yourNode; // Make sure this node doesn't already have a parent
[effectNode addChild:node];
[self addChild:effectNode];
Note that an SKScene
is an effect node, so this makes inverting an entire scene very easy:
// self is a scene here
self.filter = [CIFilter filterWithName:@"CIColorInvert"];
self.shouldEnableEffects = YES;
来源:https://stackoverflow.com/questions/28652839/is-there-a-way-to-invert-the-colors-of-a-skspritenode