新手引导可用,模版。
function UiTaskLayer:newIndex(Box,jumpname)
self.runLayer = display.getRunningScene() self.maskLayer = cc.LayerColor:create(cc.c4b(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 原文链接:https://www.f2er.com/cocos2dx/341872.html