将过滤器应用于精灵?

时间:2014-05-02 18:45:59

标签: ios sprite-kit

我正在开发一个spritekit游戏,其中id喜欢这样做我的srite的“漩涡”效果。

我在很小程度上添加的图像暗示了我想要完成的任务。

例如,如果我点击太空船(在想象中)我想在它上面使用这种“螺旋”效果(不是这个效果,而是一个旋转和扭曲我的sknode的效果。而不是整个场景。我想在我的精灵上使用CIFiler,但我读的只是图像。

任何有关此事的提示都将受到赞赏。

我有这个代码来旋转缩小播放器,只是无法弄清楚如何做漩涡模糊

 [_player runAction:
   [SKAction sequence:@[
                        [SKAction group:@[
                           [SKAction rotateByAngle:M_PI * 4 duration:1.0],
                   [SKAction scaleTo:0 duration:1.0]
                                          ]],
                        ]]];
}

enter image description here

1 个答案:

答案 0 :(得分:1)

Matt用这段代码回答了类似的问题:

UIImage *ship = [UIImage imageNamed:@"Spaceship.png"];
CIImage *shipImage = [[CIImage alloc] initWithImage:ship];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues:kCIInputImageKey, shipImage, @"inputIntensity", [NSNumber numberWithFloat:0.6], nil];
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *out = [filter outputImage];
CGImageRef cg = [context createCGImage:out fromRect:[out extent]];
SKTexture *texDone = [SKTexture textureWithCGImage:cg];

您可以在此处找到他的原始答案:SpriteKit SKTexture Crash