How to gradually blur an SKSpriteNode image using the Sprite Kit?

Can someone provide an example of how to gradually blur an SKSpriteNode image using the Apple Sprite Kit? For example, let the user touch a button on the screen, which then slowly starts the background (i.e. gradually) until it reaches a certain threshold. Ideally, I would also like to cancel this process (for example, allow the user to untie the image by pressing the same button).

+7
objective-c sprite-kit transitions skspritenode
source share
1 answer

There are two possible ways to use this, and use SKEffectNodes.

SKEffectNodes allow you to apply CI filters to a node.

There is a CI filter for Gaussian blur. So, create an SKEffectNode and assign it a blur filter, then add a button as a child.

How do you revive it?

Use SKAction to create a custom action and change the filter settings, however this can be slow and does not always give the โ€œprogressive blurโ€ effect you can expect, so I do this:

I create a filter and SKEffectNode as described above, then I bring the result to the texture using SKView.textureForNode. Then I add the resulting texture to the array, after which I loop it, continuing to apply the blur effect on top of the previous created image until I have the set number of frames. Then use the textures created to create the animation using SKAction.animateWithTextures. In my experience, this is very good.

+6
source share

All Articles