In SpriteKit, SKCropNode has no effect over a SKShapeNode

前端 未结 3 1276
面向向阳花
面向向阳花 2020-12-31 14:15

I\'ve been trying to apply a mask to a SKShapeNode using SKCropNode, and so far without success. Thinking that it\'s a SpriteKit bug - Here is the code snippet:



        
3条回答
  •  余生分开走
    2020-12-31 14:56

    I have the similar task in my app. I need to draw multiple irregular shapes based on user input and then use them as crop node's masks.

    The solution that works for me is to:

    1. create a SKShapeNode with the required path

    2. retrieve a SKTexture from it using SKView method textureFromNode:crop:

    3. create a SKSpriteNode from that texture.

    4. use SKSprite node as a mask.

提交回复
热议问题