SpriteKit crop Sprite in Node like clipToBounds in UIkit

Hi i make game Slot Machines.
I add sprite look Machines in zPosition1 and Node with Sprites describe wheel contain 50 sprites, this node move down to animate spin wheel. What best way to crop Wheel node to show items only in Slot Machine window

Hi @archideus

You could add all your sprite to the SKCropNode instance - https://developer.apple.com/documentation/spritekit/skcropnode. And all your child sprites will be cropped as you want them to be cropped.
Something like this should work:

let mask = SKSpriteNode(color: SKColor.blackColor(), size: CGSize(width: 100, height: 100))
let cropNode = SKCropNode()
cropNode.maskNode = mask
cropNode.addChild(yourNodeThatNeedsToBeCropped)\

Hope this helps.

Nikita

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.