SKLightNode 没有出现在 Sprite Kit 中

SKLightNode not showing up in Sprite Kit

我的灯:

self.light = [[SKLightNode alloc] init];
self.light.categoryBitMask = 0;
self.light.falloff = 1;
self.light.ambientColor = [UIColor whiteColor];
self.light.lightColor  = [[UIColor alloc] initWithRed:1.0 green:1.0 blue:0.0 alpha:0.5];
self.light.shadowColor = [[UIColor alloc] initWithRed:0.0 green:0.0 blue:0.0 alpha:0.3];
self.light.zPosition = 200;
[self.world addChild:self.light];

在更新时,我将灯光位置更改为角色位置。

我什么都试过了,就是看不到我的光。

向场景添加灯光并不会向场景添加白色圆圈、灯泡或类似的东西,它只是用灯光照亮一切。所以你不会"see the light",只是它的效果。

如果要查看灯光投射的阴影,必须为每个必须投射阴影的对象激活阴影。您可以通过以下方式为您的 SKNode 执行此操作:

yourSKNode.shadowCastBitMask = 1

最后,如果你想在背景上制作凹凸效果,你必须使用以下方法创建背景:

let background = SKSpriteNode(imageNamed: "theName", normalMapped: true)
background.lightingBitMask = 1