我正在关注Apple的SpriteKit文档,现在我正在尝试使用SKEffectNode,但我的问题是效果不会被应用!这是我的代码:
SKEffectNode *lightingNode = [[SKEffectNode alloc] init];
SKTexture *texture = [SKTexture textureWithImage:[UIImage imageNamed:@"Spaceship"]];
SKSpriteNode *light = [SKSpriteNode spriteNodeWithTexture:texture];
self.filter = [self blurFilter];
lightingNode.position = self.view.center;
lightingNode.blendMode = SKBlendModeAdd;
[lightingNode addChild: light];
[self addChild:lightingNode];
//applying blur
- (CIFilter *)blurFilter
{
CIFilter *filter = [CIFilter filterWithName:@"CIBoxBlur"]; // 3
[filter setDefaults];
[filter setValue:[NSNumber numberWithFloat:20] forKey:@"inputRadius"];
return filter;
}
当您运行该应用程序时,它只会显示宇宙飞船而没有任何模糊效果。