Mask for Sprite

Mask for Sprite
0.0 0



how to create a mask for a sprite? The masks are different symbols.

Like one sprite with an image and another sprite ontop of it with black and white area to define the masking area.



I think you can use CCColorLayer to do the same thing. You can see the effect of the test of LayerTest.


Not looking for this type of masks.

This is what I need:

But can be done, how I can access the alpha of a pixel of Sprite and modify


This is usually done by pixel shaders and combination of multiple textures to the one color output. But cocos implements only ES1 -> no shaders.

Try to look at this page

it’s not so powerful as shaders but you can use some predefined operations on color and alpha channels. You should be able to accomplish this goal by using proper GL***ALPHA functions.



Cocos2d-x has not affort the approach to access the data of a pixel. You can set the opacity of the entire sprite but not a pixel.


oops, AFAIK, neither cocos2d-iphone nor cocos2d-x can do this. This feature must be done by graphic designer so far, not by programmer.
Maybe cocos2d-iphone will support this in the future.




for working with RGBA of a pixel check my solution Here [[]]