cocos2d-x技術群新群:117871561
c++技術交流群:593010226
--創(chuàng)建裁剪圖片(要裁剪的形狀(模板),大辛蛩弧)
function HeadSprite:createClipImage(stencil端考,size )
--底板
local sprender = cc.Sprite:create("my.png")
sp.size = size
--創(chuàng)建裁剪
clipSp = cc.Sprite:create(stencil)
if nil ~= clipSp then
--裁剪
local clip = cc.ClippingNode:create()
-- 倒置(Inverted) 如果設置為真(true),繪制模板區(qū)域外的內(nèi)容。 默認設置為假(false)洞就,繪制模板區(qū)域內(nèi)的內(nèi)容
clip:setInverted(true)
-- alpha閾值(threshold) 只有模板(stencil)的alpha像素大于alpha閾值(alphaThreshold)時內(nèi)容才會被繪制。 alpha閾值(threshold)范圍應是0到1之間的浮點數(shù)功蜓。 alpha閾值(threshold)默認為1(alpha測試默認關閉)
--繪制裁剪區(qū)的內(nèi)容
clip:setStencil(clipSp)
--
clip:setAlphaThreshold(0)
clip:addChild(sprender)
sprender:addChild(clip)
return sprender
end
return nil
end