Mask for Sprite

Hi,

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.

Thanks!

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
http://www.khronos.org/opengles/documentation/opengles1_0/html/glBlendFunc.html

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.

Jirka

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.

Check

http://www.cocos2d-x.org/boards/6/topics/11023?r=11024#message-11024

for working with RGBA of a pixel check my solution Here [[http://stackoverflow.com/questions/9665700/getting-and-setting-the-rgb-rgba-value-of-a-pixel-in-a-ccsprite-cocos2d-x/18386538#18386538]]