请问如何设置精灵(或图层)的某个像素(或区域)的透明度

如题,想把精灵(或图层)的某一特定区域设置为透明,请问有没有什么相关的方法?
麻烦看一下附件。


mame.bmp.zip (24.3 KB)

PS

:smiley:

In fact, for pixel level control, you can use cc.RenderTexture and use canvas’s pixel control API.
Or we have also cc.ClippingNode, you can check out our test case: ClippingNodeTest -> HoleDemo

Huabin

感谢您的回复,不过我想要的效果还是无法实现,虽然用很多精灵覆盖图片到是可以实现,不过效率太低了,没有其它的办法了吗?

Hi @ying1248

You can use cc.RenderTexture to draw your image. And then with canvas’s getImageData / putImageData function, you can do pixel level modification to your image.
There are docs about canvas’ pixel manipulation like this: https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/PixelManipulation/PixelManipulation.html

Huabin