cocos2dx-lua 裁剪ClippingNode
阿新 • • 發佈:2018-08-30
ise creat 尺寸 nbsp tro mask node ima pri
註意事項:裁剪內容要用Sprite,不能換成ImageView
local imagePath = "res/yk/china/advertisement/FbIntroductionBanner.png" local maskPath = "res/yk/china/advertisement/advertisementMask535x235.png" local clippingNode = cc.ClippingNode:create() local im = cc.Sprite:create(imagePath) local mask = cc.Sprite:create(maskPath)local clipSize = mask:getContentSize() dump(clipSize) clippingNode:setContentSize(clipSize) --設置尺寸大小 clippingNode:setStencil(mask) --設置模板stencil clippingNode:setAlphaThreshold(0.05) --設置alpha閘值 -- --clippingNode:addChild(redPackage, 1) --先添加標題,會完全顯示出來,因為跟模板一樣大小 clippingNode:addChild(im,2) --會被裁減 scene:addChild(clippingNode,9999)
cocos2dx-lua 裁剪ClippingNode