SKLightNode cast shadow issue

…衆ロ難τιáo~ 提交于 2019-11-29 07:08:33

I just heard back from Apple Developer Technical Support confirming this is a bug in SpriteKit (SKLightNode). Currently they do not know of a workaround for this issue but will update me if one is found.

As per their request, I have filed a bug report.

UPDATE April 22, 2015

SK engineering confirmed that SpriteKit doesn't support shadow casting and shadowed on the same object. There is no workaround at present. This issue will be addressed at some point.

UPDATE December 15, 2015

Received a new response from Apple regarding this issue.

Apple Developer Relations 14-Dec-2015 01:35 PM

There are no plans to address this.

We are now closing this report.

I'v found some workaround (not sure it's useful for all situation, but in some): You can make two (or more - up to 32 as we know) different light sources and assign you sprites to them one by one (or by some groups). Then shadows will combine as we need - correctly.

SKLightNode* light1 = [SKLightNode new];
SKLightNode* light2 = [SKLightNode new];

... // init them equally

light1.categoryBitMask = 1;
light2.categoryBitMask = 2;
...

SKSpriteNode* sprite1 = ...
SKSpriteNode* sprite2 = ...

sp1.shadowCastBitMask = 1;
sp1.shadowedBitMask = 1;
sp2.shadowCastBitMask = 2;
sp2.shadowedBitMask = 2;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!