新手引导可用,模版。
function UiTaskLayer:newIndex(box , jumpname)
self.runLayer = display.getRunningScene()self.maskLayer = cc.LayerColor:create(cc.c4b(0,0,0, 0)):pos(400,300)
self.maskLayer:setContentSize(cc.size(300,200))
self.maskLayer:setOpacity(0)
self.runLayer:addChild(self.maskLayer,20000)
local function onTouchStart(touch, event)
local point = touch:getLocation()
local rect = box:convertToWorldSpace(ccp(0,0))
local convert_rectSucc = box:getBoundingBox()
convert_rectSucc.x = rect.x
convert_rectSucc.y = rect.y
if cc.rectContainsPoint(convert_rectSucc,point) then
self.clicklistener:setSwallowTouches(false)
else
self.clicklistener:setSwallowTouches(true)
end
return true
end
self.clicklistener = cc.EventListenerTouchOneByOne:create()
self.clicklistener:setSwallowTouches(true)
self.clicklistener:registerScriptHandler( onTouchStart,cc.Handler.EVENT_TOUCH_BEGAN )
local eventDispatcher = self.maskLayer:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(self.clicklistener,self.maskLayer )
end