In Swift/SpriteKit Can you use a ShapeNode as mask in a CropNode
I've been trying to combine randomised SKShapeNode
shapes with textures using a SKCropNode
но это не похоже на работу. Я предполагаю что SKCropNodes
only work with bitmap graphics such as PNG.
//define sprite as crop node
let cropSprite = SKCropNode()
//create spriteNode with texture and add it
let texSprite = SKSpriteNode(imageNamed: "rock")
cropSprite.addChild(texSprite)
//set mask of cropping Sprite to (predefined) shape node with .maskNode
cropSprite.maskNode = myShapeNode
//add final cropped sprite to scene
self.addChild(cropSprite)
In this case nothing appears. If I don't set the:
cropNode.maskNode = myShapeNode
the cropSprite appears as a normal sprite with a texture added.
Есть идеи?
Большое спасибо, Кв