Learn iOS SpriteKit with Examples, Code Snippets and Video Tutorials

How to mask with Sprite Kit

How to mask with Sprite Kit
January 10, 2014 Justin

Masking is quite easy with Sprite Kit. Easier than I thought it would be, and you copy and paste this into the init statement of your Sprite Kit scene, you’ll see the always-included spaceship image get masked down to a 100 by 100 square.

So we’ve got three objects here. The pictureToMask,  mask, and cropNode.   The pictureToMask is added as a child of the cropNode. The mask object isn’t actually added as a child of anything (oddly enough), but as you can see setMaskNode is called on the cropNode with the mask as a parameter. So the cropNode is basically a container with the pictureToMask in it, and the mask as a property.


Justin Dike is the owner and lead developer at CartoonSmart.com. He's taught hundreds of hours of game development video tutorials, covering everything from coding to art. These days he's working mostly on Swift and Sprite Kit tutorials, which often lead into highly polished iOS / tvOS Starter Kits, which require no programming at all, but are capable of making nearly any type game! Yeah, you read that write. You can also find Justin at the official CartoonSmart Podcast


Leave a reply

Check out our premium Swift and Sprite Kit Tutorial content!

Visit CartoonSmart.com