本文主要是介绍cocos2dx - lua 中实现遮罩层和屏蔽层,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
--遮罩层local maskLayer = CCLayerColor:create(ccc4(0, 0, 0, 120), visibleSize.width, visibleSize.height);self:addChild(maskLayer)--触摸屏蔽层local touchLayer = CCLayer:create();touchLayer:setContentSize(CCSize(visibleSize.width, visibleSize.height))local function touchLayerCallFunc(eventType, x, y)--LuaLog("======000========", eventType)--LuaLog("======111========", x)--LuaLog("======222========", y)//在began触摸时,返回true,消息将被拦截,这样就实现了屏蔽层if eventType == "began" thenreturn trueendend--这个函数的使用我在这篇博客中有说明(http://blog.csdn.net/tianxiawuzhei/article/details/46011101)touchLayer:registerScriptTouchHandler(touchLayerCallFunc, false, newPriority, true)touchLayer:setTouchEnabled(true)maskLayer:addChild(touchLayer)
总结:
其实上面两个层可以和为一个层,因为CCLayerColor本身就是继承自CCLayer,所以同样可以实现触摸屏蔽。
这里只是为了看起来更清晰。
这篇关于cocos2dx - lua 中实现遮罩层和屏蔽层的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!