Is there a way in Sprite Kit that I can capture the screen (all the current SKScene
rendered nodes) to an SKTexture
so that I can apply a CIFilter and then assign the SKTexture back to a new SKSpriteNode
?
I know that I can set an SKEffectNode
, as the parent of my node tree, apply a filter etc and get the result that way but I really need to have a filtered SKTexture
(or SKSpriteNode
) that I can reuse later?
Possible solution:
textureFromNode:
Renders and returns a Sprite Kit texture that contains the node’s contents.
Yup that works:
SKTexture *texture = [[self view] textureFromNode:[self scene]];
[blurSprite setTexture:texture];
From Apple docs:
textureFromNode: Renders and returns a Sprite Kit texture that contains the node’s contents.
Code example:
SKTexture *texture = [[self view] textureFromNode:[self scene]];
[blurSprite setTexture:texture];
You should try with snapshotViewAfterScreenUpdates:
method from UIView
.
Your SKScene
is inside an SKView
that has this method.
After that you can extract the image from the view, and create a SKNode
with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With