在startling裡的displayobject物件會存在乙個mask的變數,可以把各種形狀賦值進去,來得到乙個新的圖形。其形狀不止侷限於矩形,甚至多邊形,圓形或者更複雜的組合。這一切可以使用canvas來實現多邊形圓形。
var image:image = new image(texture);
var quad:quad = new quad(100,100);
quad.x = 50;
quad.y = 50;
image.mask = quad;
這裡已經實現了乙個簡易的方塊遮罩。
var canvas:canves = new canves();
canvas.beginfill(0x0);
//這裡的arr儲存多邊形的頂點座標
canvas.drawpolygon(new polygon(arr));
canvas.x = 50;
canvas.y = 50;
//同樣,可以使用自定義的頂點座標來遮罩出乙個新的圖案
image.mask = canvas;
利用canves的自定義頂點的功能,來實現乙個自定義圖形的遮罩。
truedepthandstencil>
請在initwindow標籤裡新增這個配置,否則會導致mask不可用。 cocos2dx 3 x 蒙板 遮罩 點選圓功能
註冊觸控 eventlistenertouchonebyone listener eventlistenertouchonebyone create listener ontouchbegan cc callback 2 helloworld ontouchbegan,this listener o...
unity遮罩 2 對罩子做處理
遮罩技術是乙個基本的技術方法,有很多很多中用法.你可以在flash中經常看到遮罩的使用,它可以另一些視覺元素更加驚豔.當我看到unity中沒有包含任何幾何體和的遮罩技術很不爽,不過,幸運的我找到了解決方案,就是 depth mask 著色器.先看看著色器的 沒錯,非常短.shader depth m...
製作精靈遮罩cocos2dx3 0
sprite helloworld maskedspritewithsprite sprite texturesprite,sprite masksprite 這句話可以去掉 texturesprite setblendfunc blendfunc 4 rt begin masksprite vis...