SKEffectionNodes have a shouldRasterise "switch" that bakes them into a bitmap, and doesn't update them until such time as the underlying nodes that are impacted by the effect are changed.
However I can't find a way to create an SKTexture from this rasterised "image".
Is it possible to get a SKTexture from a SKEffectNode?
I've figured this out, in a way that solves my problems, using a Factory.
Read more on how to make a factory, from BenMobile's patient and clear articulation, here: Factory creation and use for making Sprites and Shapes
There's an issue with blurring a
SKTextureorSKSpriteNodein that it's going to run out of space. The blur/glow goes beyond the edges of the sprite. To solve this, in the below, you'll see I've created a "framer" object. This is simply an emptySKSpriteNodethat's double the size of the texture to be blurred. The texture to be blurred is added as a child, to this "framer" object.It works, regardless of how hacky this is ;)
Inside a static factory class file:
Inside anywhere you can access the Sprite you want to make a shadow or glow texture for:
-
buttonis a texture of the button to be given a shadow.a:is an alpha setting (actually transparency level, 0.0 to 1.0, where 1.0 is fully opaque) the lower this is the lighter the shadow will be.The positioning serves to drop the shadow slightly below the button so it looks like light is coming from the top, casting shadows down and onto the background.