Hi. I am attempting to render a complex space scene in which I have many sprites. I am using Cocos2d-x 2.2. I need the ability to mask a moving sprite with a static sprite or stencil a layer in the shape of the mask, both of which I am having problems with. I have been able to get the moving mask working but it relies on me shifting and updating the moving sprite every frame which becomes very slow. The code I am using for this is from https://github.com/syuhari/CCMask. I have also taken a look at the option of having a stencil but have only found examples of stenciling out rectangles and simple shapes. What I need is to stencil out a sprite.
Here are some example images to demonstrate:
I want this:
given the stars background and this mask
Yes, I realize I can get away without using a mask in this first example here but I also need to mask clouds moving on the planet and if I need two masks, simply layer hiding won’t work. A moving mask or a layer mask with a sprite stencil is exactly what I am after.
Does anyone know how to mask a sprite with another sprite and allow the sprite to move while the mask stays put.
Does anyone know how I would use the mask image I provided to create a clipping layer or stencil or whatever it is called so that it would not draw anything on the star layer past the start of the planet.
Thank you for your time. Also, if I am confused in any terminology, please correct me. I’m here to learn.