我的灯:
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];
在更新时,我将灯光位置更改为角色位置。
我什么都试过了,就是看不到我的光。
最佳答案
向场景添加灯光并不会在场景中添加白色圆圈、灯泡或类似的东西,它只是用灯光照亮一切。所以您不会“看到光”,只会看到它的效果。
如果您想看到灯光转换的阴影,您必须为每个必须转换阴影的对象激活阴影。您可以通过以下方式为您的 SKNode 执行此操作:
yourSKNode.shadowCastBitMask = 1
最后,如果你想在背景上制作凹凸效果,你必须使用以下方法创建背景:
let background = SKSpriteNode(imageNamed: "theName", normalMapped: true)
background.lightingBitMask = 1
关于ios - SKLightNode 没有出现在 Sprite Kit 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33258793/