不知道为什么这不起作用。
当它尝试创建 ship 节点时,它会因 EXC_BAD_ACCESS 而崩溃。
SKTexture *tex = [SKTexture textureWithImageNamed:@"Spaceship"];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"];
[filter setValue:@0.6 forKey:kCIInputIntensityKey];
SKTexture *texDone;
if (filter) {
texDone = [tex textureByApplyingCIFilter:filter];
}
if (texDone) {
SKSpriteNode *ship = [SKSpriteNode spriteNodeWithTexture:texDone];
[self addChild:ship];
ship.position = CGPointMake(200, 200);
}
和造船一样的崩溃。
我已经使用了这个 SKEffect,但它的代码更多吗?对于相同的过滤器。以下作品。
SKSpriteNode *spriteToFilter = [SKSpriteNode spriteNodeWithImageNamed:@"Spaceship"];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"];
[filter setValue:@1.0 forKey:kCIInputIntensityKey];
SKEffectNode *effectNode = [SKEffectNode node];
effectNode.filter = filter;
effectNode.shouldEnableEffects = YES;
[effectNode addChild:spriteToFilter];
[self addChild:effectNode];
effectNode.position = CGPointMake(200, 200);