clippingNode新手引导
来源:互联网 发布:java io读取文件 编辑:程序博客网 时间:2024/06/05 08:38
GameLayer.lua
GameLayer = class("GameLayer",function() return cc.Layer:create()end)function GameLayer:create() local view = GameLayer.new() view:__init() return viewendfunction GameLayer:__init() local whiteColor = cc.c3b(255,255,255) local layerColor = cc.LayerColor:create(whiteColor) self:addChild(layerColor) local btn1 = ButtonEx:create("按钮1", function() end) btn1:setPosition(winSizeWidth/2 - 100,winSizeHeight/2) self:addChild(btn1) local btn2 = ButtonEx:create("按钮2", function() end) btn2:setPosition(winSizeWidth/2,winSizeHeight/2) self:addChild(btn2) local btn3 = ButtonEx:create("按钮3", function() end) btn3:setPosition(winSizeWidth/2 + 100,winSizeHeight/2) self:addChild(btn3) local callback = function() local scene = cc.Scene:create() scene:addChild(SecondLayer:create()) cc.Director:getInstance():replaceScene(scene) end self:addChild(GuideLayer:create({btn2}, callback))endGuideLayer.lua
GuideLayer = class("GuideLayer",function() return cc.Layer:create()end)function GuideLayer:create(nodeList, callback) local view = GuideLayer.new() view:__init(nodeList, callback) return viewendlocal function onTouchBegan(touch, event) local gameLayer = event:getCurrentTarget() local locationInNode = touch:getLocation() gameLayer.touchListener:setSwallowTouches(false) for i, v in ipairs(gameLayer.nodeList) do local node = gameLayer.nodeList[i] local s = node:getContentSize() local rect = cc.rect(node:getPositionX() - s.width/2, node:getPositionY() - s.height/2, s.width, s.height) if cc.rectContainsPoint(rect, locationInNode) then if gameLayer.callback then gameLayer.callback() end return false end end gameLayer.touchListener:setSwallowTouches(true) return trueendfunction GuideLayer:__init(nodeList, callback) self.nodeList = nodeList self.callback = callback --1. local clippingNode = cc.ClippingNode:create() self:addChild(clippingNode) --2.被裁剪的层 local grayLayer = cc.LayerColor:create(grayColor) grayLayer:setOpacity(150) clippingNode:addChild(grayLayer) --3.镂空模型 local stencil = cc.Node:create() clippingNode:setStencil(stencil) clippingNode:setInverted(true) clippingNode:setAlphaThreshold(0.05) --镂空具体的区域 for i, v in ipairs(nodeList) do local node = nodeList[i] local layer = cc.LayerColor:create(grayColor, node:getContentSize().width, node:getContentSize().height) layer:setPosition(node:getPositionX() -node:getContentSize().width/2, node:getPositionY() -node:getContentSize().height/2) stencil:addChild(layer) end --事件触摸 local touchListener = cc.EventListenerTouchOneByOne:create() touchListener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN) cc.Director:getInstance():getEventDispatcher():addEventListenerWithSceneGraphPriority(touchListener, self) self.touchListener = touchListenerend
阅读全文
0 0
- clippingNode 新手引导
- clippingNode新手引导
- ClippingNode 新手引导 高亮选择提示
- lua版本ClippingNode实现新手引导
- 用封装ClippingNode实现新手引导(cocos2dx 3.2版本)
- cocos2dx 3.0 用ClippingNode做游戏的新手引导
- Cocos2dx 3.0 过渡篇(十六)用ClippingNode做游戏的新手引导
- Cocos2dx 3.0 过渡篇(十六)用ClippingNode做游戏的新手引导
- 新手引导
- 新手引导
- 新手引导
- 新手引导
- ClippingNode做游戏的新手指导
- ClippingNode
- ClippingNode
- ClippingNode
- ClippingNode
- 游戏新手引导设计
- 22. Generate Parentheses
- DTD--eclipse中设置XML文件自动补全的方法步骤
- js自适应rem -- 主要适用于移动端
- 第一篇博客
- spring集成webservice框架cxf,访问报错service not found
- clippingNode新手引导
- javascript获取地址栏各字段方法
- Mysql怎么同步两个不同库的不同表以及部分字段
- linux小工具安装
- 打包生成桌台二维码
- 使用IDEA新建一个Spring Boot项目
- 在Qt中移植VPU编解码程序时遇到的问题
- C语言小碎片七
- python enumerate