How to create an alpha mask in iOS using sprite kit

爱⌒轻易说出口 提交于 2019-11-30 21:55:43

A very simple (and maybe less... or more performant) version of this would be to simply add a SKSpriteNode on top which has your vignette on a transparent background. In other words, if viewed in Photoshop, you would see a decreasing amount of checkerboard visible in the circle as you go from the center out, eventually displaying solid black. When the PNG image is used in your app, this transparency will be preserved when the two sprites are composited.

I have an idea... I hope it would help.

Make a PNG with the gradient you want from white to black with no transparency.

Use a separate sprite node with the png for each light you want and add them all to a SKEffectNode or SKCropNode node. It doesn't matter which since they are both rendered in a separate context. Set each sprite node to screen blending mode.

Then, when adding the parent SKEffectNode or SKCropNode to the scene, set it to multiply blend mode.

In the end, the screening will merge the "lights" together nicely, while the multiply will make the white area transparent.

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