Transform any polygon into a mask with Corona SDK

This bit comes directly from our library.
Instead of creating each needed mask manually, we found it easier to simply choose a display object, a polygon, and mask the object using the chosen polygon. We would then either run the app as is, or go into our documents directory and take the created mask so that we could use it anywhere.

If you need to mask a single image, it’s still easier to simply fill the polygon with the image itself with Graphics 2.0.
But for groups of objects, animated sprites and the likes, this made everything so much easier (;

To use it, you just need to require our library, and call the proper function, passing a display object, the polygon you wish to use as a mask, and a name for the mask that will be created.


Get the project from here.

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">