第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

cocos2dx怎么得到一個(gè)指定layer?

cocos2dx怎么得到一個(gè)指定layer?

莫回?zé)o 2018-08-28 11:07:11
cocos2dx怎么得到一個(gè)指定layer
查看完整描述

1 回答

?
DIEA

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超3個(gè)贊

--創(chuàng)建一個(gè)touch的半透明layer
--priority : touch 權(quán)限級(jí)別,默認(rèn)為-1024
--touchRect: 在touchRect 區(qū)域會(huì)放行touch事件 若touchRect = nil 則全屏吃touch
--touchCallback: 屏蔽層touch 回調(diào)
function createMaskLayer( priority,touchRect ,touchCallback, layerOpacity,highRect)
local layer = CCLayer:create()
layer:setPosition(ccp(0, 0))
layer:setAnchorPoint(ccp(0, 0))
layer:setTouchEnabled(true)
layer:setTouchPriority(priority or -1024)
layer:registerScriptTouchHandler(function ( eventType,x,y )
if(eventType == "began") then
if(touchRect == nil) then
if(touchCallback ~= nil) then
touchCallback()
end
return true
else
if(touchRect:containsPoint(ccp(x,y))) then
return false
else
if(touchCallback ~= nil) then
touchCallback()
end
return true
end
end
end
print(eventType)
end,false, priority or -1024, true)

local gw,gh = g_winSize.width, g_winSize.height
if(touchRect == nil) then
local layerColor = CCLayerColor:create(ccc4(0,0,0,layerOpacity or 150),gw,gh)
layerColor:setPosition(ccp(0,0))
layerColor:setAnchorPoint(ccp(0,0))
layer:addChild(layerColor)
return layer
else
local ox,oy,ow,oh = touchRect.origin.x, touchRect.origin.y, touchRect.size.width, touchRect.size.height
local layerColor = CCLayerColor:create(ccc4(0, 0, 0, layerOpacity or 150 ), gw, gh)

local clipNode = CCClippingNode:create();
clipNode:setInverted(true)
clipNode:addChild(layerColor)

local stencilNode = CCNode:create()
-- stencilNode:retain()

local node = CCScale9Sprite:create("bg.png");
node:setContentSize(CCSizeMake(ow, oh))
node:setAnchorPoint(ccp(0, 0))
node:setPosition(ccp(ox, oy))
stencilNode:addChild(node)

if(highRect ~= nil) then
local highNode = CCScale9Sprite:create("bg.png");
highNode:setContentSize(CCSizeMake(highRect.size.width, highRect.size.height))
highNode:setAnchorPoint(ccp(0, 0))
highNode:setPosition(ccp(highRect.origin.x, highRect.origin.y))
stencilNode:addChild(highNode)
end

clipNode:setStencil(stencilNode)
clipNode:setAlphaThreshold(0.5)
layer:addChild(clipNode)
end
return layer
end

查看完整回答
反對(duì) 回復(fù) 2018-09-20
  • 1 回答
  • 0 關(guān)注
  • 1079 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)