Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios game make a mask layer effect

enter image description hereI need a 'mask' layer that covers the whole screen, with the center part (a circle) to be transparent. Then I can move the mask layer around using touch. User are only able to see the transparent part in the middle.

I don't think a png file can help because the file need to be very large to cover the whole screen.

So is it possible to do it by coding?

i found this online, but don't know much about openGL. http://www.cocos2d-iphone.org/forum/topic/7921.

it would be great if i can use a CCMaskLayer and input with the radius. i can handle the touch event by my self.

the attached png file is expected result, the center part is transparent. i need this to cover my screen, and only show the middle part. the red part is covered.

like image 858
OMGPOP Avatar asked Dec 12 '25 21:12

OMGPOP


1 Answers

I write a CCMaskLayer to do the exactly same thing.

https://github.com/smilingpoplar/CCMaskLayer

like image 109
smilingpoplar Avatar answered Dec 14 '25 13:12

smilingpoplar